From ed08cfe4cd05b81e9dbdf33866c8e292a424fb67 Mon Sep 17 00:00:00 2001 From: Michael Koch Date: Wed, 25 Sep 2002 05:05:07 +0000 Subject: [PATCH] 2002-09-25 Michael Koch * java/net/DatagramPacket (DatagramPacket): Exception documentation added. (setData): Likewise. (setSocketAddress): Likewise. * java/net/DatagramSocketImpl.java (peek): Documentation addded. (peekData): Documentation addded. (send): Documentation addded. (receive): Documentation addded. (connect): New method. (disconnect): New method. (joinGroup): New abstract method. (leaveGroup): New abstract method. * java/net/InetSocketAddress.java (InetSocketAddress): Documentation added. (equals): final keyword added. (getAddress): final keyword added. (getHostName): final keyword added. (getPort): final keyword added. (hashCode): final keyword added. (isUnresolved): final keyword added. * java/net/MulticastSocket.java (MulticastSocket): Documentation added. (MulticastSocket): New method. (joinGroup): Documentation added. (joinGroup): New method. (leaveGroup): Documentation added. (leaveGroup): New method. (send): Documentation added. * java/net/NetworkInterface.java (getByName): Documentation added. (getByInetAddress): Documentation added. (getNetworkInterfaces): Documentation added. * java/net/PlainDatagramSocketImpl.java (connect): New method. (disconnect): New method. * java/net/SocketImpl.java (create): Documentation added. (shutdownInput): Convert public to protected, as it always was. (shutdownOutput): Convert public to protected, as it always was. * java/net/SocketOptions.java (whole file): Reintented. * java/net/URLClassLoader.java (URLClassLoader): SecurityManager check added, documentation added. (findResources): Documentation added. (findClass): Documentation added. (newInstance): More correct method arguments. * java/net/URLConnection.java (connect): Documentation added. (getContent): Documentation added. (getPermission): Documentation added. (getInputStream): Documentation added. (getOutputStream): Documentation added. (setDoInput): Throw correct exception, documentation added. (setDoOutput): Throw correct exception, documentation added. (setAllowUserInteraction): Throw correct exception, documentation added. (setUseCaches): Throw correct exception, documentation added. (setIfModifiedSince): Throw correct exception, documentation added. (setRequestProperty): Throw exception, documentation added. (addRequestProperty): Throw exception, documentation added. (getRequestProperty): Throw exception, documentation added. (getRequestProperties): Documentation added. (setContentHandlerFactory): Documentation added. (guessContentTypeFromName): protected to public. (setFileNameMap): Documentation added. * java/net/URLDecoder.java (URLDecoder): New method. (decode): Documentation added. (whole file): Reindented. * java/net/URLEncoder.java (encode): Documentation added. * java/net/natPlainDatagramSocketImpl.cc (connect): New method. (disconnect): New method. * javax/naming/RefAddr: (addrType): addrType was never final. (equals): Fix typo in method name. * javax/naming/BinaryRefAddr: (equals): Fix typo in method name. From-SVN: r57487 --- libjava/ChangeLog | 86 ++++++++- libjava/java/net/DatagramPacket.java | 11 +- libjava/java/net/DatagramSocketImpl.java | 66 +++++++ libjava/java/net/InetSocketAddress.java | 18 +- libjava/java/net/MulticastSocket.java | 91 +++++++++ libjava/java/net/NetworkInterface.java | 8 + libjava/java/net/PlainDatagramSocketImpl.java | 3 + libjava/java/net/SocketImpl.java | 6 +- libjava/java/net/SocketOptions.java | 249 ++++++++++++------------- libjava/java/net/URLClassLoader.java | 43 ++++- libjava/java/net/URLConnection.java | 67 ++++++- libjava/java/net/URLDecoder.java | 108 ++++++----- libjava/java/net/URLEncoder.java | 3 + libjava/java/net/natPlainDatagramSocketImpl.cc | 29 +++ libjava/javax/naming/BinaryRefAddr.java | 2 +- libjava/javax/naming/RefAddr.java | 4 +- 16 files changed, 584 insertions(+), 210 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 7d56136..62339d0 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,85 @@ +2002-09-25 Michael Koch + + * java/net/DatagramPacket + (DatagramPacket): Exception documentation added. + (setData): Likewise. + (setSocketAddress): Likewise. + * java/net/DatagramSocketImpl.java + (peek): Documentation addded. + (peekData): Documentation addded. + (send): Documentation addded. + (receive): Documentation addded. + (connect): New method. + (disconnect): New method. + (joinGroup): New abstract method. + (leaveGroup): New abstract method. + * java/net/InetSocketAddress.java + (InetSocketAddress): Documentation added. + (equals): final keyword added. + (getAddress): final keyword added. + (getHostName): final keyword added. + (getPort): final keyword added. + (hashCode): final keyword added. + (isUnresolved): final keyword added. + * java/net/MulticastSocket.java + (MulticastSocket): Documentation added. + (MulticastSocket): New method. + (joinGroup): Documentation added. + (joinGroup): New method. + (leaveGroup): Documentation added. + (leaveGroup): New method. + (send): Documentation added. + * java/net/NetworkInterface.java + (getByName): Documentation added. + (getByInetAddress): Documentation added. + (getNetworkInterfaces): Documentation added. + * java/net/PlainDatagramSocketImpl.java + (connect): New method. + (disconnect): New method. + * java/net/SocketImpl.java + (create): Documentation added. + (shutdownInput): Convert public to protected, as it always was. + (shutdownOutput): Convert public to protected, as it always was. + * java/net/SocketOptions.java + (whole file): Reintented. + * java/net/URLClassLoader.java + (URLClassLoader): SecurityManager check added, documentation added. + (findResources): Documentation added. + (findClass): Documentation added. + (newInstance): More correct method arguments. + * java/net/URLConnection.java + (connect): Documentation added. + (getContent): Documentation added. + (getPermission): Documentation added. + (getInputStream): Documentation added. + (getOutputStream): Documentation added. + (setDoInput): Throw correct exception, documentation added. + (setDoOutput): Throw correct exception, documentation added. + (setAllowUserInteraction): Throw correct exception, documentation added. + (setUseCaches): Throw correct exception, documentation added. + (setIfModifiedSince): Throw correct exception, documentation added. + (setRequestProperty): Throw exception, documentation added. + (addRequestProperty): Throw exception, documentation added. + (getRequestProperty): Throw exception, documentation added. + (getRequestProperties): Documentation added. + (setContentHandlerFactory): Documentation added. + (guessContentTypeFromName): protected to public. + (setFileNameMap): Documentation added. + * java/net/URLDecoder.java + (URLDecoder): New method. + (decode): Documentation added. + (whole file): Reindented. + * java/net/URLEncoder.java + (encode): Documentation added. + * java/net/natPlainDatagramSocketImpl.cc + (connect): New method. + (disconnect): New method. + * javax/naming/RefAddr: + (addrType): addrType was never final. + (equals): Fix typo in method name. + * javax/naming/BinaryRefAddr: + (equals): Fix typo in method name. + 2002-09-22 Tom Tromey Fix for PR libgcj/6576: @@ -40,8 +122,8 @@ 2002-09-19 Tom Tromey - * java/lang/ClassLoader.java (resolveClass0): Set cause for - newly-created exception. + * java/lang/ClassLoader.java (resolveClass0): Set cause for + newly-created exception. 2002-09-18 Michael Koch diff --git a/libjava/java/net/DatagramPacket.java b/libjava/java/net/DatagramPacket.java index 836f5dd..7fbb3f8 100644 --- a/libjava/java/net/DatagramPacket.java +++ b/libjava/java/net/DatagramPacket.java @@ -195,6 +195,7 @@ public final class DatagramPacket * @param address The socket address to send to * * @exception SocketException If an error occurs + * @exception IllegalArgumentException If address type is not supported * * @since 1.4 */ @@ -215,6 +216,7 @@ public final class DatagramPacket * @param address The socket address to send to * * @exception SocketException If an error occurs + * @exception IllegalArgumentException If address type is not supported * * @since 1.4 */ @@ -321,7 +323,7 @@ public final class DatagramPacket * * @param address The socket address of the remove host * - * @exception IllegalArgumentException If an error occurs + * @exception IllegalArgumentException If address type is not supported * * @since 1.4 */ @@ -353,6 +355,8 @@ public final class DatagramPacket * * @param buf The new buffer for this packet * + * @exception NullPointerException If the argument is null + * * @since 1.1 */ public synchronized void setData(byte[] buf) @@ -372,6 +376,8 @@ public final class DatagramPacket * @param offset The offset into the buffer to start reading data from. * @param length The number of bytes of data in the buffer. * + * @exception NullPointerException If the argument is null + * * @since 1.2 */ public synchronized void setData(byte[] buf, int offset, int length) @@ -398,6 +404,9 @@ public final class DatagramPacket * * @param length The new length. (Where len <= buf.length) * + * @exception IllegalArgumentException f the length is negative or + * if the length is greater than the packet's data buffer length + * * @since 1.1 */ public synchronized void setLength(int length) diff --git a/libjava/java/net/DatagramSocketImpl.java b/libjava/java/net/DatagramSocketImpl.java index 6f10a78..5a0aa3e 100644 --- a/libjava/java/net/DatagramSocketImpl.java +++ b/libjava/java/net/DatagramSocketImpl.java @@ -108,6 +108,9 @@ public abstract class DatagramSocketImpl implements SocketOptions * @return The port number of the sender of the packet * * @exception IOException If an error occurs + * @exception PortUnreachableException May be thrown if the socket is + * connected to a currently unreachable destination. Note, there is no + * guarantee that the exception will be thrown. */ protected abstract int peek(InetAddress i) throws IOException; @@ -120,6 +123,9 @@ public abstract class DatagramSocketImpl implements SocketOptions * @return The port number of the sender of the packet. * * @exception IOException If an error occurs + * @exception PortUnreachableException May be thrown if the socket is + * connected to a currently unreachable destination. Note, there is no + * guarantee that the exception will be thrown. * * @since 1.4 */ @@ -132,6 +138,9 @@ public abstract class DatagramSocketImpl implements SocketOptions * @param p The packet to send * * @exception IOException If an error occurs + * @exception PortUnreachableException May be thrown if the socket is + * connected to a currently unreachable destination. Note, there is no + * guarantee that the exception will be thrown. */ protected abstract void send(DatagramPacket p) throws IOException; @@ -143,10 +152,38 @@ public abstract class DatagramSocketImpl implements SocketOptions * @param p A place to store the incoming packet. * * @exception IOException If an error occurs + * @exception PortUnreachableException May be thrown if the socket is + * connected to a currently unreachable destination. Note, there is no + * guarantee that the exception will be thrown. */ protected abstract void receive(DatagramPacket p) throws IOException; /** + * Connects the socket to a host specified by address and port. + * + * @param address The InetAddress of the host to connect to + * @param port The port number of the host to connect to + * + * @exception SocketException If an error occurs + * + * @since 1.4 + */ + protected void connect (InetAddress address, int port) throws SocketException + { + // This method has to be overwritten by real implementations + } + + /** + * Disconnects the socket. + * + * @since 1.4 + */ + protected void disconnect () + { + // This method has to be overwritten by real implementations + } + + /** * Sets the Time to Live (TTL) setting on this socket to the specified * value. Use setTimeToLive(int) instead. * @@ -203,6 +240,35 @@ public abstract class DatagramSocketImpl implements SocketOptions protected abstract void leave(InetAddress inetaddr) throws IOException; /** + * Causes this socket to join the specified multicast group on a specified + * device + * + * @param mcastaddr The address to leave + * @param netIf The specified network interface to join the group at + * + * @exception IOException If an error occurs + * + * @since 1.4 + */ + protected abstract void joinGroup (SocketAddress mcastaddr, + NetworkInterface netIf) + throws IOException; + + /** + * Leaves a multicast group + * + * @param mcastaddr The address to join + * @param netIf The specified network interface to leave the group at + * + * @exception IOException If an error occurs + * + * @since 1.4 + */ + protected abstract void leaveGroup (SocketAddress mcastaddr, + NetworkInterface netIf) + throws IOException; + + /** * Returns the FileDescriptor for this socket */ protected FileDescriptor getFileDescriptor() diff --git a/libjava/java/net/InetSocketAddress.java b/libjava/java/net/InetSocketAddress.java index 4a4f736..20ebbfa 100644 --- a/libjava/java/net/InetSocketAddress.java +++ b/libjava/java/net/InetSocketAddress.java @@ -73,7 +73,7 @@ public class InetSocketAddress extends SocketAddress * * @param port Port if the socket * - * @exception IllegalArgumentException If the port number is illegel + * @exception IllegalArgumentException If the port number is illegal */ public InetSocketAddress(int port) throws IllegalArgumentException @@ -91,9 +91,11 @@ public class InetSocketAddress extends SocketAddress /** * Constructs an InetSocketAddress instance. - * + * * @param addr Address of the socket * @param port Port if the socket + * + * @exception IllegalArgumentException If the port number is illegal */ public InetSocketAddress(String hostname, int port) throws IllegalArgumentException @@ -112,7 +114,7 @@ public class InetSocketAddress extends SocketAddress * Test if obj is a InetSocketAddress and * has the same address & port */ - public boolean equals(Object obj) + public final boolean equals(Object obj) { if (obj instanceof InetSocketAddress) { @@ -122,17 +124,17 @@ public class InetSocketAddress extends SocketAddress return false; } - public InetAddress getAddress() + public final InetAddress getAddress() { return addr; } - public String getHostName() + public final String getHostName() { return addr.getHostName(); } - public int getPort() + public final int getPort() { return port; } @@ -140,7 +142,7 @@ public class InetSocketAddress extends SocketAddress /** * TODO: see what sun does here. */ - public int hashCode() + public final int hashCode() { return port + addr.hashCode(); } @@ -148,7 +150,7 @@ public class InetSocketAddress extends SocketAddress /** * TODO: see what sun does here. */ - public boolean isUnresolved() + public final boolean isUnresolved() { return addr == null; } diff --git a/libjava/java/net/MulticastSocket.java b/libjava/java/net/MulticastSocket.java index 88cb149..b358260 100644 --- a/libjava/java/net/MulticastSocket.java +++ b/libjava/java/net/MulticastSocket.java @@ -73,6 +73,8 @@ public class MulticastSocket extends DatagramSocket * Create a MulticastSocket that this not bound to any address * * @exception IOException If an error occurs + * @exception SecurityException If a security manager exists and its + * checkListen method doesn't allow the operation */ public MulticastSocket() throws IOException { @@ -85,6 +87,8 @@ public class MulticastSocket extends DatagramSocket * @param port The port to bind to * * @exception IOException If an error occurs + * @exception SecurityException If a security manager exists and its + * checkListen method doesn't allow the operation */ public MulticastSocket(int port) throws IOException { @@ -92,6 +96,22 @@ public class MulticastSocket extends DatagramSocket } /** + * Create a multicast socket bound to the specified SocketAddress. + * + * @param address The SocketAddress the multicast socket will be bound to + * + * @exception IOException If an error occurs + * @exception SecurityException If a security manager exists and its + * checkListen method doesn't allow the operation + * + * @since 1.4 + */ + public MulticastSocket(SocketAddress address) throws IOException + { + super(address); + } + + /** * Returns the interface being used for multicast packets * * @return The multicast interface @@ -232,6 +252,7 @@ public class MulticastSocket extends DatagramSocket * @param addr The address of the group to join * * @exception IOException If an error occurs + * @exception SecurityException FIXME */ public void joinGroup(InetAddress mcastaddr) throws IOException { @@ -251,6 +272,7 @@ public class MulticastSocket extends DatagramSocket * @param addr The address of the group to leave * * @exception IOException If an error occurs + * @exception SecurityException FIXME */ public void leaveGroup(InetAddress mcastaddr) throws IOException { @@ -265,6 +287,74 @@ public class MulticastSocket extends DatagramSocket } /** + * Joins the specified mulitcast group on a specified interface. + * + * @param mcastaddr The multicast address to join + * @param netIf The local network interface to receive the multicast + * messages on or null to defer the interface set by #setInterface or + * #setNetworkInterface + * + * @exception IOException If an error occurs + * @exception IllegalArgumentException If address type is not supported + * @exception SecurityException FIXME + * + * @see MulticastSocket:setInterface + * @see MulticastSocket:setNetworkInterface + * + * @since 1.4 + */ + public void joinGroup(SocketAddress mcastaddr, NetworkInterface netIf) + throws IOException + { + if (! (mcastaddr instanceof InetSocketAddress)) + throw new IllegalArgumentException ("SocketAddress type not supported"); + + InetSocketAddress tmp = (InetSocketAddress) mcastaddr; + + if (! tmp.getAddress ().isMulticastAddress ()) + throw new IOException ("Not a Multicast address"); + + // FIXME: check if this check is sufficient. Do we need to check the port ? + SecurityManager s = System.getSecurityManager (); + if (s != null) + s.checkMulticast (tmp.getAddress ()); + + impl.joinGroup (mcastaddr, netIf); + } + + /** + * Leaves the specified mulitcast group on a specified interface. + * + * @param mcastaddr The multicast address to leave + * @param netIf The local networki interface or null to defer to the + * interface set by setInterface or setNetworkInterface + * + * @exception IOException If an error occurs + * @exception IllegalArgumentException If address type is not supported + * @exception SecurityException FIXME + * + * @see MulticastSocket:setInterface + * @see MulticastSocket:setNetworkInterface + * + * @since 1.4 + */ + public void leaveGroup(SocketAddress mcastaddr, NetworkInterface netIf) + throws IOException + { + InetSocketAddress tmp = (InetSocketAddress) mcastaddr; + + if (! tmp.getAddress ().isMulticastAddress ()) + throw new IOException ("Not a Multicast address"); + + // FIXME: do we need to check the port too, or is this sufficient ? + SecurityManager s = System.getSecurityManager (); + if (s != null) + s.checkMulticast (tmp.getAddress ()); + + impl.leaveGroup (mcastaddr, netIf); + } + + /** * Sends a packet of data to a multicast address with a TTL that is * different from the default TTL on this socket. The default TTL for * the socket is not changed. @@ -273,6 +363,7 @@ public class MulticastSocket extends DatagramSocket * @param ttl The TTL for this packet * * @exception IOException If an error occurs + * @exception SecurityException FIXME */ public synchronized void send(DatagramPacket p, byte ttl) throws IOException { diff --git a/libjava/java/net/NetworkInterface.java b/libjava/java/net/NetworkInterface.java index d42e69d..f0113d0 100644 --- a/libjava/java/net/NetworkInterface.java +++ b/libjava/java/net/NetworkInterface.java @@ -118,6 +118,9 @@ public final class NetworkInterface * Returns an network interface by name * * @param name The name of the interface to return + * + * @exception SocketException If an error occurs + * @exception NullPointerException If the specified name is null */ public static NetworkInterface getByName (String name) throws SocketException @@ -141,6 +144,9 @@ public final class NetworkInterface * Return a network interface by its address * * @param addr The address of the interface to return + * + * @exception SocketException If an error occurs + * @exception NullPointerException If the specified addess is null */ public static NetworkInterface getByInetAddress (InetAddress addr) throws SocketException @@ -167,6 +173,8 @@ public final class NetworkInterface /** * Return an Enumeration of all available network interfaces + * + * @exception SocketException If an error occurs */ public static Enumeration getNetworkInterfaces () throws SocketException diff --git a/libjava/java/net/PlainDatagramSocketImpl.java b/libjava/java/net/PlainDatagramSocketImpl.java index 54f5c2e..118021d 100644 --- a/libjava/java/net/PlainDatagramSocketImpl.java +++ b/libjava/java/net/PlainDatagramSocketImpl.java @@ -63,6 +63,9 @@ class PlainDatagramSocketImpl extends DatagramSocketImpl protected native void bind(int lport, InetAddress laddr) throws SocketException; + protected native void connect (InetAddress i, int port) + throws SocketException; + protected native void disconnect (); protected native void create() throws SocketException; protected native int peek(InetAddress i) throws IOException; protected native int peekData (DatagramPacket dp) throws IOException; diff --git a/libjava/java/net/SocketImpl.java b/libjava/java/net/SocketImpl.java index 1c90499..795e713 100644 --- a/libjava/java/net/SocketImpl.java +++ b/libjava/java/net/SocketImpl.java @@ -95,6 +95,8 @@ public abstract class SocketImpl implements SocketOptions * if the stream parameter is false. * * @param stream true for a stream socket, false for a datagram socket + * + * @exception IOException If an error occurs */ protected abstract void create(boolean stream) throws IOException; @@ -311,7 +313,7 @@ public abstract class SocketImpl implements SocketOptions * * @exception IOException if an error occurs */ - public abstract void shutdownInput () throws IOException; + protected abstract void shutdownInput () throws IOException; /** * Shut down the output side of this socket. Subsequent writes will @@ -319,5 +321,5 @@ public abstract class SocketImpl implements SocketOptions * * @exception IOException if an error occurs */ - public abstract void shutdownOutput () throws IOException; + protected abstract void shutdownOutput () throws IOException; } diff --git a/libjava/java/net/SocketOptions.java b/libjava/java/net/SocketOptions.java index fda637e..628e08e 100644 --- a/libjava/java/net/SocketOptions.java +++ b/libjava/java/net/SocketOptions.java @@ -43,142 +43,125 @@ package java.net; */ /** - * This interface is used by SocketImpl and - * DatagramSocketImpl to implement options - * on sockets. - * - * @since 1.2 - * - * @author Aaron M. Renn (arenn@urbanophile.com) - * @author Warren Levy - * @status should be completely JDK 1.4 compatible - */ + * This interface is used by SocketImpl and + * DatagramSocketImpl to implement options + * on sockets. + * + * @since 1.2 + * + * @author Aaron M. Renn (arenn@urbanophile.com) + * @author Warren Levy + * @status should be completely JDK 1.4 compatible + */ public interface SocketOptions { - -/*************************************************************************/ - -/* - * Static Variables - */ - -/** - * Option id for the SO_KEEPALIVE value - * @since 1.3 - */ -static final int SO_KEEPALIVE = 0x8; + /** + * Option id for the SO_KEEPALIVE value + * @since 1.3 + */ + static final int SO_KEEPALIVE = 0x8; -/** - * Option id for the SO_LINGER value - */ -static final int SO_LINGER = 0x80; // 128 - -/** - * Option id for the SO_TIMEOUT value - */ -static final int SO_TIMEOUT = 0x1006; // 4102 - -/** - * Retrieve the local address to which the socket is bound. - */ -static final int SO_BINDADDR = 0x0F; // 15 - -/** - * Option id for the send buffer size - * @since 1.2 - */ -static final int SO_SNDBUF = 0x1001; // 4097 - -/** - * Option id for the receive buffer size - * @since 1.2 - */ -static final int SO_RCVBUF = 0x1002; // 4098 - -/** - * Sets the SO_REUSEADDR parameter on a socket - */ -static final int SO_REUSEADDR = 0x04; // 4 - -/** - * Sets SO_BROADCAST for a socket - * @since 1.4 - */ -static final int SO_BROADCAST = 0x20; // 32 - -/** - * Sets SO_OOBINLINE for a socket - * @since 1.4 - */ -static final int SO_OOBINLINE = 0x1003; // 4099 - -/** - * Option id for the TCP_NODELAY value - */ -static final int TCP_NODELAY = 0x01; // 1 - -/** - * Options id for the IP_MULTICAST_IF value - */ -static final int IP_MULTICAST_IF = 0x10; // 16 - -/** - * same as above - * @since 1.4 - */ -static final int IP_MULTICAST_IF2 = 0x1F; // 31 - -/** - * This option enables or disables local loopback of multicast datagrams. - * @since 1.4 - */ -static final int IP_MULTICAST_LOOP = 0x12; // 18 - -/** - * This option sets the type-of-service or traffic class field in the - * IP header for a TCP or UDP socket. - * @since 1.4 - */ -static final int IP_TOS = 0x03; // 3 - -/*************************************************************************/ - -/* - * Interface Methods - */ - -/** - * Sets the specified option on a socket to the passed in object. For - * options that take an integer argument, the passed in object is an - * Integer. For options that are set to on or off, the - * value passed will be a Boolean. The option_id - * parameter is one of the defined constants in this interface. - * - * @param option_id The identifier of the option - * @param val The value to set the option to - * - * @exception SocketException If an error occurs - */ -void -setOption(int option_id, Object val) throws SocketException; - -/*************************************************************************/ - -/** - * Returns the current setting of the specified option. The - * Object returned will be an Integer for options - * that have integer values. For options that are set to on or off, a - * Boolean will be returned. The option_id - * is one of the defined constants in this interface. - * - * @param option_id The option identifier - * - * @return The current value of the option - * - * @exception SocketException If an error occurs - */ -Object -getOption(int option_id) throws SocketException; + /** + * Option id for the SO_LINGER value + */ + static final int SO_LINGER = 0x80; // 128 + + /** + * Option id for the SO_TIMEOUT value + */ + static final int SO_TIMEOUT = 0x1006; // 4102 + + /** + * Retrieve the local address to which the socket is bound. + */ + static final int SO_BINDADDR = 0x0F; // 15 + + /** + * Option id for the send buffer size + * @since 1.2 + */ + static final int SO_SNDBUF = 0x1001; // 4097 + + /** + * Option id for the receive buffer size + * @since 1.2 + */ + static final int SO_RCVBUF = 0x1002; // 4098 + + /** + * Sets the SO_REUSEADDR parameter on a socket + */ + static final int SO_REUSEADDR = 0x04; // 4 + + /** + * Sets SO_BROADCAST for a socket + * @since 1.4 + */ + static final int SO_BROADCAST = 0x20; // 32 + + /** + * Sets SO_OOBINLINE for a socket + * @since 1.4 + */ + static final int SO_OOBINLINE = 0x1003; // 4099 + + /** + * Option id for the TCP_NODELAY value + */ + static final int TCP_NODELAY = 0x01; // 1 + + /** + * Options id for the IP_MULTICAST_IF value + */ + static final int IP_MULTICAST_IF = 0x10; // 16 + + /** + * same as above + * @since 1.4 + */ + static final int IP_MULTICAST_IF2 = 0x1F; // 31 + + /** + * This option enables or disables local loopback of multicast datagrams. + * @since 1.4 + */ + static final int IP_MULTICAST_LOOP = 0x12; // 18 + + /** + * This option sets the type-of-service or traffic class field in the + * IP header for a TCP or UDP socket. + * @since 1.4 + */ + static final int IP_TOS = 0x03; // 3 + + /** + * Sets the specified option on a socket to the passed in object. For + * options that take an integer argument, the passed in object is an + * Integer. For options that are set to on or off, the + * value passed will be a Boolean. The option_id + * parameter is one of the defined constants in this interface. + * + * @param option_id The identifier of the option + * @param val The value to set the option to + * + * @exception SocketException If an error occurs + */ + void setOption(int option_id, Object val) throws SocketException; + + /** + * Returns the current setting of the specified option. The + * Object returned will be an Integer for options + * that have integer values. For options that are set to on or off, a + * Boolean will be returned. The option_id + * is one of the defined constants in this interface. + * + * @param option_id The option identifier + * + * @return The current value of the option + * + * @exception SocketException If an error occurs + */ + Object getOption(int option_id) throws SocketException; } // interface SocketOptions diff --git a/libjava/java/net/URLClassLoader.java b/libjava/java/net/URLClassLoader.java index 7e59c66..5e059cf 100644 --- a/libjava/java/net/URLClassLoader.java +++ b/libjava/java/net/URLClassLoader.java @@ -40,11 +40,23 @@ public class URLClassLoader extends SecureClassLoader return null; } + /** + * Createa a new URL class loader object + * + * @exception SecurityException If a security manager exists and its + * checkCreateClassLoader method doesn't allow creation of a class loader + */ public URLClassLoader (URL[] urls) { this (urls, null, null); } - + + /** + * Createa a new URL class loader object + * + * @exception SecurityException If a security manager exists and its + * checkCreateClassLoader method doesn't allow creation of a class loader + */ public URLClassLoader (URL[] urls, ClassLoader parent) { this (urls, parent, null); @@ -100,11 +112,21 @@ public class URLClassLoader extends SecureClassLoader info.addElement (conn); } + /** + * Createa a new URL class loader object + * + * @exception SecurityException If a security manager exists and its + * checkCreateClassLoader method doesn't allow creation of a class loader + */ public URLClassLoader (URL[] urls, ClassLoader parent, URLStreamHandlerFactory fac) { super (parent); + SecurityManager s = System.getSecurityManager(); + if (s != null) + s.checkCreateClassLoader(); + factory = fac; if (urls == null || urls.length == 0) @@ -150,7 +172,13 @@ public class URLClassLoader extends SecureClassLoader path.copyInto (urls); return urls; } - + + /** + * Returns an Enumeration of URLs representing all of the resources on the + * URL search path having the specified name + * + * @exception IOException If an error occurs + */ public Enumeration findResources (String name) { Vector results = new Vector (); @@ -224,7 +252,12 @@ public class URLClassLoader extends SecureClassLoader return null; } - // and finally, we can implement our class loader functionality. + /** + * Finds and loads the class with the specified name from the + * URL search path + * + * @exception ClassNotFoundException If the class could not be found + */ protected Class findClass (String name) throws ClassNotFoundException { @@ -404,7 +437,7 @@ public class URLClassLoader extends SecureClassLoader * system class loader. * @param urls the initial URLs used to resolve classes and resources */ - public static URLClassLoader newInstance(URL urls[]) throws + public static URLClassLoader newInstance(URL[] urls) throws SecurityException { return new URLClassLoader(urls); @@ -416,7 +449,7 @@ public class URLClassLoader extends SecureClassLoader * @param urls the initial URLs used to resolve classes and resources * @param parent the parent class loader */ - public static URLClassLoader newInstance(URL urls[], + public static URLClassLoader newInstance(URL[] urls, ClassLoader parent) throws SecurityException { diff --git a/libjava/java/net/URLConnection.java b/libjava/java/net/URLConnection.java index 548479d..91c229d 100644 --- a/libjava/java/net/URLConnection.java +++ b/libjava/java/net/URLConnection.java @@ -72,6 +72,8 @@ public abstract class URLConnection /** * Creates a real connection to the object references by the URL given * to the constructor + * + * @exception IOException If an error occurs */ public abstract void connect() throws IOException; @@ -229,6 +231,10 @@ 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() throws IOException { @@ -248,6 +254,9 @@ public abstract class URLConnection * 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. + * + * @exception IOException If the computation of the permission requires + * network or file I/O and an exception occurs while computing it */ public Permission getPermission() throws IOException { @@ -257,6 +266,9 @@ public abstract class URLConnection /** * Returns the input stream of the URL connection + * + * @exception IOException If an error occurs + * @exception UnknownServiceException If the protocol does not support input */ public InputStream getInputStream() throws IOException { @@ -267,6 +279,9 @@ public abstract class URLConnection /** * Returns the output stream of the URL connection + * + * @exception IOException If an error occurs + * @exception UnknownServiceException If the protocol does not support output */ public OutputStream getOutputStream() throws IOException { @@ -287,11 +302,13 @@ public abstract class URLConnection * Sets tha value of the doInput field. * * @param doinput The new value of the doInput field + * + * @exception IllegalStateException If already connected */ public void setDoInput(boolean doinput) { if (connected) - throw new IllegalAccessError("Already connected"); + throw new IllegalStateException ("Already connected"); doInput = doinput; } @@ -308,11 +325,13 @@ public abstract class URLConnection * Sets the value of the doOutput field * * @param dooutput The new value of the doOutput field + * + * @exception IllegalStateException If already connected */ public void setDoOutput(boolean dooutput) { if (connected) - throw new IllegalAccessError("Already connected"); + throw new IllegalStateException ("Already connected"); doOutput = dooutput; } @@ -329,11 +348,13 @@ public abstract class URLConnection * Sets a new value to the allowUserInteraction field * * @param allowed The new value + * + * @exception IllegalStateException If already connected */ public void setAllowUserInteraction(boolean allowed) { if (connected) - throw new IllegalAccessError("Already connected"); + throw new IllegalStateException ("Already connected"); allowUserInteraction = allowed; } @@ -368,11 +389,13 @@ public abstract class URLConnection * Sets a new value to the useCaches field * * @param usecaches The new value + * + * @exception IllegalStateException If already connected */ public void setUseCaches(boolean usecaches) { if (connected) - throw new IllegalAccessError("Already connected"); + throw new IllegalStateException ("Already connected"); useCaches = usecaches; } @@ -390,11 +413,13 @@ public abstract class URLConnection * * @param ifmodifiedsince The new value in milliseconds * since January 1, 1970 GMT + * + * @exception IllegalStateException If already connected */ public void setIfModifiedSince(long ifmodifiedsince) { if (connected) - throw new IllegalAccessError("Already connected"); + throw new IllegalStateException ("Already connected"); ifModifiedSince = ifmodifiedsince; } @@ -431,11 +456,17 @@ public abstract class URLConnection * @param key Key of the property to set * @param value Value of the Property to set * + * @exception IllegalStateException If already connected + * @exception NullPointerException If key is null + * * @see URLConnection:getRequestProperty(String key) - * @see URLConnection:addRequestProperty/String key, String value) + * @see URLConnection:addRequestProperty(String key, String value) */ public void setRequestProperty(String key, String value) { + if (connected) + throw new IllegalStateException ("Already connected"); + // Do nothing unless overridden by subclasses that support setting // header fields in the request. } @@ -446,6 +477,9 @@ public abstract class URLConnection * * @param key Key of the property to add * @param value Value of the Property to add + * + * @exception IllegalStateException If already connected + * @exception NullPointerException If key is null * * @see URLConnection:getRequestProperty(String key) * @see URLConnection:setRequestProperty(String key, String value) @@ -454,6 +488,9 @@ public abstract class URLConnection */ public void addRequestProperty(String key, String value) { + if (connected) + throw new IllegalStateException ("Already connected"); + if (getRequestProperty (key) == null) { setRequestProperty (key, value); @@ -465,6 +502,8 @@ public abstract class URLConnection * * @param key Key of the property to return * + * @exception IllegalStateException If already connected + * * @see URLConnection:setRequestProperty(String key, String value) * @see URLConnection:addRequestProperty(String key, String value) * @@ -472,6 +511,9 @@ public abstract class URLConnection */ public String getRequestProperty(String key) { + if (connected) + throw new IllegalStateException ("Already connected"); + // Overridden by subclasses that support reading header fields from the // request. return null; @@ -480,6 +522,8 @@ public abstract class URLConnection /** * Returns a map that contains all properties of the request * + * @exception IllegalStateException If already connected + * * @return The map of properties */ public Map getRequestProperties() @@ -526,6 +570,10 @@ public abstract class URLConnection * Sets a ContentHandlerFactory * * @param fac The ContentHandlerFactory + * + * @exception Error If the factory has already been defined + * @exception SecurityException If a security manager exists and its + * checkSetFactory method doesn't allow the operation */ public static void setContentHandlerFactory(ContentHandlerFactory fac) { @@ -545,8 +593,10 @@ public abstract class URLConnection * specified file name * * @param fname The filename to guess the content type from + * + * @specnote public since JDK 1.4 */ - protected static String guessContentTypeFromName(String fname) + public static String guessContentTypeFromName(String fname) { int dot = fname.lastIndexOf ("."); @@ -597,6 +647,9 @@ public abstract class URLConnection * Sets a FileNameMap * * @param map The new FileNameMap + * + * @exception SecurityException If a security manager exists and its + * checkSetFactory method doesn't allow the operation * * @since 1.2 */ diff --git a/libjava/java/net/URLDecoder.java b/libjava/java/net/URLDecoder.java index 3c15802..8cdcf94 100644 --- a/libjava/java/net/URLDecoder.java +++ b/libjava/java/net/URLDecoder.java @@ -39,38 +39,45 @@ package java.net; import java.io.UnsupportedEncodingException; - /** - * This utility class contains static methods that converts a - * string encoded in the x-www-form-urlencoded format to the original - * text. The x-www-form-urlencoded format replaces certain disallowed - * characters with encoded equivalents. All upper case and lower case - * letters in the US alphabet remain as is, the space character (' ') - * is replaced with '+' sign, and all other characters are converted to a - * "%XX" format where XX is the hexadecimal representation of that character - * in a given character encoding (default is "UTF-8"). - *

- * This method is very useful for decoding strings sent to CGI scripts - * - * Written using on-line Java Platform 1.2/1.4 API Specification. - * Status: Believed complete and correct. - * - * @since 1.2 - * - * @author Warren Levy - * @author Aaron M. Renn (arenn@urbanophile.com) (documentation comments) - * @author Mark Wielaard (mark@klomp.org) - */ +/** + * This utility class contains static methods that converts a + * string encoded in the x-www-form-urlencoded format to the original + * text. The x-www-form-urlencoded format replaces certain disallowed + * characters with encoded equivalents. All upper case and lower case + * letters in the US alphabet remain as is, the space character (' ') + * is replaced with '+' sign, and all other characters are converted to a + * "%XX" format where XX is the hexadecimal representation of that character + * in a given character encoding (default is "UTF-8"). + *

+ * This method is very useful for decoding strings sent to CGI scripts + * + * Written using on-line Java Platform 1.2/1.4 API Specification. + * Status: Believed complete and correct. + * + * @since 1.2 + * + * @author Warren Levy + * @author Aaron M. Renn (arenn@urbanophile.com) (documentation comments) + * @author Mark Wielaard (mark@klomp.org) + */ public class URLDecoder { - /** - * This method translates the passed in string from x-www-form-urlencoded - * format using the default encoding "UTF-8" to decode the hex encoded - * unsafe characters. - * - * @param s the String to convert - * - * @return the converted String - */ + /** + * Constructor for compatibility with Sun's JDK. + */ + public URLDecoder () + { + } + + /** + * This method translates the passed in string from x-www-form-urlencoded + * format using the default encoding "UTF-8" to decode the hex encoded + * unsafe characters. + * + * @param s the String to convert + * + * @return the converted String + */ public static String decode(String s) { try @@ -84,25 +91,28 @@ public class URLDecoder } } - /** - * This method translates the passed in string from x-www-form-urlencoded - * format using the given character encoding to decode the hex encoded - * unsafe characters. - *

- * This implementation will decode the string even if it contains - * unsafe characters (characters that should have been encoded) or if the - * two characters following a % do not represent a hex encoded byte. - * In those cases the unsafe character or the % character will be added - * verbatim to the decoded result. - * - * @param s the String to convert - * @param encoding the character encoding to use the decode the hex encoded - * unsafe characters - * - * @return the converted String - * - * @since 1.4 - */ + /** + * This method translates the passed in string from x-www-form-urlencoded + * format using the given character encoding to decode the hex encoded + * unsafe characters. + * + * This implementation will decode the string even if it contains + * unsafe characters (characters that should have been encoded) or if the + * two characters following a % do not represent a hex encoded byte. + * In those cases the unsafe character or the % character will be added + * verbatim to the decoded result. + * + * @param s the String to convert + * @param encoding the character encoding to use the decode the hex encoded + * unsafe characters + * + * @return the converted String + * + * @exception UnsupportedEncodingException If the named encoding is not + * supported + * + * @since 1.4 + */ public static String decode(String s, String encoding) throws UnsupportedEncodingException { diff --git a/libjava/java/net/URLEncoder.java b/libjava/java/net/URLEncoder.java index e3b6b63..345ef24 100644 --- a/libjava/java/net/URLEncoder.java +++ b/libjava/java/net/URLEncoder.java @@ -94,6 +94,9 @@ public class URLEncoder * * @return The converted String * + * @exception UnsupportedEncodingException If the named encoding is not + * supported + * * @since 1.4 */ public static String encode(String s, String encoding) diff --git a/libjava/java/net/natPlainDatagramSocketImpl.cc b/libjava/java/net/natPlainDatagramSocketImpl.cc index cf11925..82e2806 100644 --- a/libjava/java/net/natPlainDatagramSocketImpl.cc +++ b/libjava/java/net/natPlainDatagramSocketImpl.cc @@ -86,6 +86,20 @@ java::net::PlainDatagramSocketImpl::bind (jint, java::net::InetAddress *) JvNewStringLatin1 ("DatagramSocketImpl.bind: unimplemented")); } +void +java::net::PlainDatagramSocketImpl::connect (java::net::InetAddress *, jint) +{ + throw new java::io::SocketException ( + JvNewStringLatin1 ("DatagramSocketImpl.connect: unimplemented")); +} + +void +java::net::PlainDatagramSocketImpl::disconnect () +{ + throw new java::io::SocketException ( + JvNewStringLatin1 ("DatagramSocketImpl.disconnect: unimplemented")); +} + jint java::net::PlainDatagramSocketImpl::peek (java::net::InetAddress *) { @@ -265,6 +279,21 @@ java::net::PlainDatagramSocketImpl::bind (jint lport, throw new java::net::BindException (JvNewStringUTF (strerr)); } +void +java::net::PlainDatagramSocketImpl::connect (java::net::InetAddress *addr, + jint port) +{ + throw new ::java::lang::InternalError ( + JvNewStringLatin1 ("PlainDatagramSocketImpl::connect: not implemented yet")); +} + +void +java::net::PlainDatagramSocketImpl::disconnect () +{ + throw new ::java::lang::InternalError ( + JvNewStringLatin1 ("PlainDatagramSocketImpl::disconnect: not implemented yet")); +} + jint java::net::PlainDatagramSocketImpl::peek (java::net::InetAddress *i) { diff --git a/libjava/javax/naming/BinaryRefAddr.java b/libjava/javax/naming/BinaryRefAddr.java index 29ca33d..d0a3a03 100644 --- a/libjava/javax/naming/BinaryRefAddr.java +++ b/libjava/javax/naming/BinaryRefAddr.java @@ -97,7 +97,7 @@ public class BinaryRefAddr extends RefAddr * the addrType is the same as this addrType and the bytes of the * content are the same. */ - public boolean equal(Object o) + public boolean equals(Object o) { if (o instanceof BinaryRefAddr) { diff --git a/libjava/javax/naming/RefAddr.java b/libjava/javax/naming/RefAddr.java index 9ed504f..a1c096c 100644 --- a/libjava/javax/naming/RefAddr.java +++ b/libjava/javax/naming/RefAddr.java @@ -61,7 +61,7 @@ public abstract class RefAddr implements Serializable * The string resprenstation of the type of address. * Set by the constructor and returned by the getType() method. */ - protected final String addrType; + protected String addrType; /** * Protected constructor for use by subclasses. @@ -98,7 +98,7 @@ public abstract class RefAddr implements Serializable * is the same as this addrType and the content is equals to the * content of this object. */ - public boolean equal(Object o) + public boolean equals(Object o) { if (o instanceof RefAddr) { -- 2.7.4