aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wielaard <mark@gcc.gnu.org>2005-11-17 20:38:40 +0000
committerMark Wielaard <mark@gcc.gnu.org>2005-11-17 20:38:40 +0000
commitf4e1433a02a9bd5e2ddecd0d346d57876ad53307 (patch)
tree235cbb7c11fda8c95f6e2e1920237d047af0d32b
parent11922361e4a39efa05cc2a807d656dc5bfb858b3 (diff)
downloadgcc-f4e1433a02a9bd5e2ddecd0d346d57876ad53307.zip
gcc-f4e1433a02a9bd5e2ddecd0d346d57876ad53307.tar.gz
gcc-f4e1433a02a9bd5e2ddecd0d346d57876ad53307.tar.bz2
[multiple changes]
2005-11-17 Mark Wielaard <mark@klomp.org> * gnu/java/net/protocol/file/Handler.java: Removed, fully merged now. * java/net/ServerSocket.java: Likewise. * sources.am: Regenerated. * Makefile.in: Regenerated. 2005-11-17 Mark Wielaard <mark@klomp.org> Fixes bug #24006 * java/net/ServerSocket.java (implAccept): Set Socket.bound to true. 2005-11-17 Tom Tromey <tromey@redhat.com> * java/net/ServerSocket.java (accept): Use correct security manager call. 2005-11-17 Jeroen Frijters <jeroen@frijters.net> * java/net/ServerSocket.java (bound): Removed. (local): New field. (bind): Cache local socket address. (getInetAddress, getLocalPort, getLocalSocketAddress, isBound): Use cached local socket address. (close): bound field was removed. 2005-11-17 Tom Tromey <tromey@redhat.com> * java/net/URLConnection.java (setDoInput): Javadoc fix. (setDoOutput): Likewise. (setContentHandlerFactory): Likewise. (setFileNameMap): Likewise. 2005-11-17 Mark Wielaard <mark@klomp.org> * java/net/URLClassloader.java (addURLs): Add comment about jboss. 2005-11-17 Mark Wielaard <mark@klomp.org> * java/net/URLClassLoader.java (addURLs): Don't call addURL(), but call urls.add() and addURLImpl() directly on each URL. 2005-11-17 Tom Tromey <tromey@redhat.com> * java/net/URLClassLoader.java (definePackage): Javadoc fixes. 2005-11-17 Jeroen Frijters <jeroen@frijters.net> * java/net/URLClassLoader.java (Resource.name): Removed field. (JarURLResource.name): Added field. (FileResource.getURL): Use File.toURL() instead of doing it in a way that breaks on Windows. 2005-11-17 Roman Kennke <roman@kennke.org> Reported by: Ingo Proetel <proetel@aicas.com> * java/net/URLClassLoader.java (findClass): Added null check to avoid NullPointerException. 2005-11-17 David Gilbert <david.gilbert@object-refinery.com> * java/net/URLClassLoader.java: reordered some API doc comments to suppress Eclipse warnings, and fixed API doc link. 2005-11-17 Tom Tromey <tromey@redhat.com> * java/net/URLClassLoader.java (URLClassLoader): Removed unused constructor. 2005-11-17 Jeroen Frijters <jeroen@frijters.net> * java/net/URLClassLoader (findClass): Close InputStream after we're done with it. From-SVN: r107133
-rw-r--r--libjava/ChangeLog76
-rw-r--r--libjava/Makefile.in6
-rw-r--r--libjava/gnu/java/net/protocol/file/Handler.java91
-rw-r--r--libjava/java/net/ServerSocket.java609
-rw-r--r--libjava/java/net/URLClassLoader.java159
-rw-r--r--libjava/java/net/URLConnection.java8
-rw-r--r--libjava/sources.am6
7 files changed, 166 insertions, 789 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 31962c6..512b4f1 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,79 @@
+2005-11-17 Mark Wielaard <mark@klomp.org>
+
+ * gnu/java/net/protocol/file/Handler.java: Removed, fully merged now.
+ * java/net/ServerSocket.java: Likewise.
+ * sources.am: Regenerated.
+ * Makefile.in: Regenerated.
+
+2005-11-17 Mark Wielaard <mark@klomp.org>
+
+ Fixes bug #24006
+ * java/net/ServerSocket.java (implAccept): Set Socket.bound to true.
+
+2005-11-17 Tom Tromey <tromey@redhat.com>
+
+ * java/net/ServerSocket.java (accept): Use correct security manager
+ call.
+
+2005-11-17 Jeroen Frijters <jeroen@frijters.net>
+
+ * java/net/ServerSocket.java
+ (bound): Removed.
+ (local): New field.
+ (bind): Cache local socket address.
+ (getInetAddress, getLocalPort, getLocalSocketAddress, isBound):
+ Use cached local socket address.
+ (close): bound field was removed.
+
+2005-11-17 Tom Tromey <tromey@redhat.com>
+
+ * java/net/URLConnection.java (setDoInput): Javadoc fix.
+ (setDoOutput): Likewise.
+ (setContentHandlerFactory): Likewise.
+ (setFileNameMap): Likewise.
+
+2005-11-17 Mark Wielaard <mark@klomp.org>
+
+ * java/net/URLClassloader.java (addURLs): Add comment about jboss.
+
+2005-11-17 Mark Wielaard <mark@klomp.org>
+
+ * java/net/URLClassLoader.java (addURLs): Don't call addURL(), but
+ call urls.add() and addURLImpl() directly on each URL.
+
+2005-11-17 Tom Tromey <tromey@redhat.com>
+
+ * java/net/URLClassLoader.java (definePackage): Javadoc fixes.
+
+2005-11-17 Jeroen Frijters <jeroen@frijters.net>
+
+ * java/net/URLClassLoader.java
+ (Resource.name): Removed field.
+ (JarURLResource.name): Added field.
+ (FileResource.getURL): Use File.toURL() instead of doing it in
+ a way that breaks on Windows.
+
+2005-11-17 Roman Kennke <roman@kennke.org>
+
+ Reported by: Ingo Proetel <proetel@aicas.com>
+ * java/net/URLClassLoader.java
+ (findClass): Added null check to avoid NullPointerException.
+
+2005-11-17 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/net/URLClassLoader.java: reordered some API doc comments to
+ suppress Eclipse warnings, and fixed API doc link.
+
+2005-11-17 Tom Tromey <tromey@redhat.com>
+
+ * java/net/URLClassLoader.java (URLClassLoader): Removed
+ unused constructor.
+
+2005-11-17 Jeroen Frijters <jeroen@frijters.net>
+
+ * java/net/URLClassLoader (findClass): Close InputStream after we're
+ done with it.
+
2005-11-17 Bryce McKinlay <mckinlay@redhat.com>
Implement -Xss.
diff --git a/libjava/Makefile.in b/libjava/Makefile.in
index 6daf7a3..ac07ecf 100644
--- a/libjava/Makefile.in
+++ b/libjava/Makefile.in
@@ -1426,9 +1426,9 @@ gnu/java/net/protocol/gcjlib/Handler.java
gnu_java_net_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_net_source_files)))
gnu_java_net_protocol_file_source_files = \
gnu/java/net/protocol/file/Connection.java \
-gnu/java/net/protocol/file/Handler.java
+classpath/gnu/java/net/protocol/file/Handler.java
-gnu_java_net_protocol_file_header_files = $(patsubst %.java,%.h,$(gnu_java_net_protocol_file_source_files))
+gnu_java_net_protocol_file_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_net_protocol_file_source_files)))
gnu_java_net_protocol_ftp_source_files = \
classpath/gnu/java/net/protocol/ftp/ActiveModeDTP.java \
classpath/gnu/java/net/protocol/ftp/BlockInputStream.java \
@@ -2801,7 +2801,7 @@ classpath/java/net/NoRouteToHostException.java \
classpath/java/net/PasswordAuthentication.java \
classpath/java/net/PortUnreachableException.java \
classpath/java/net/ProtocolException.java \
-java/net/ServerSocket.java \
+classpath/java/net/ServerSocket.java \
classpath/java/net/Socket.java \
classpath/java/net/SocketAddress.java \
classpath/java/net/SocketException.java \
diff --git a/libjava/gnu/java/net/protocol/file/Handler.java b/libjava/gnu/java/net/protocol/file/Handler.java
deleted file mode 100644
index fc56049..0000000
--- a/libjava/gnu/java/net/protocol/file/Handler.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/* Handler.java -- "file" protocol handler for java.net
- Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.java.net.protocol.file;
-
-import java.io.IOException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLStreamHandler;
-
-/**
- * This is the protocol handler for the "file" protocol.
- * It implements the abstract openConnection() method from
- * URLStreamHandler by returning a new FileURLConnection object (from
- * this package). All other methods are inherited
- *
- * @author Aaron M. Renn (arenn@urbanophile.com)
- * @author Warren Levy (warrenl@cygnus.com)
- */
-public class Handler extends URLStreamHandler
-{
- /**
- * A do nothing constructor
- */
- public Handler()
- {
- }
-
- /**
- * This method returs a new FileURLConnection for the specified URL
- *
- * @param url The URL to return a connection for
- *
- * @return The URLConnection
- *
- * @exception IOException If an error occurs
- */
- protected URLConnection openConnection(URL url) throws IOException
- {
- // If a hostname is set, then we need to switch protocols to ftp
- // in order to transfer this from the remote host.
- String host = url.getHost();
- if ((host != null) && (! host.equals("")))
- {
- // Reset the protocol (and implicitly the handler) for this URL.
- // Then have the URL attempt the connection again, as it will
- // get the changed handler the next time around.
- // If the ftp protocol handler is not installed, an
- // exception will be thrown from the new openConnection() call.
- setURL (url, "ftp", url.getHost(), url.getPort(), url.getFile(),
- url.getRef());
- return url.openConnection();
- }
-
- return new Connection(url);
- }
-} // class Handler
diff --git a/libjava/java/net/ServerSocket.java b/libjava/java/net/ServerSocket.java
deleted file mode 100644
index 85604fe..0000000
--- a/libjava/java/net/ServerSocket.java
+++ /dev/null
@@ -1,609 +0,0 @@
-/* ServerSocket.java -- Class for implementing server side sockets
- Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004
- Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package java.net;
-
-import gnu.java.net.PlainSocketImpl;
-
-import java.io.IOException;
-import java.nio.channels.IllegalBlockingModeException;
-import java.nio.channels.ServerSocketChannel;
-
-
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: I believe all methods are implemented.
- */
-
-/**
- * This class models server side sockets. The basic model is that the
- * server socket is created and bound to some well known port. It then
- * listens for and accepts connections. At that point the client and
- * server sockets are ready to communicate with one another utilizing
- * whatever application layer protocol they desire.
- *
- * As with the <code>Socket</code> class, most instance methods of this class
- * simply redirect their calls to an implementation class.
- *
- * @author Aaron M. Renn (arenn@urbanophile.com)
- * @author Per Bothner (bothner@cygnus.com)
- */
-public class ServerSocket
-{
- /**
- * This is the user defined SocketImplFactory, if one is supplied
- */
- private static SocketImplFactory factory;
-
- /**
- * This is the SocketImp object to which most instance methods in this
- * class are redirected
- */
- private SocketImpl impl;
-
- /**
- * True if socket is bound.
- */
- private boolean bound;
-
- /*
- * This constructor is only used by java.nio.
- */
-
- // FIXME: Workaround a bug in gcj.
- //ServerSocket (PlainSocketImpl impl) throws IOException
- ServerSocket(SocketImpl impl) throws IOException
- {
- if (impl == null)
- throw new NullPointerException("impl may not be null");
-
- this.impl = impl;
- this.impl.create(true);
- }
-
- /*
- * This method is only used by java.nio.
- */
-
- // FIXME: Workaround a bug in gcj.
- //PlainSocketImpl getImpl()
- SocketImpl getImpl()
- {
- return impl;
- }
-
- /**
- * Constructor that simply sets the implementation.
- *
- * @exception IOException If an error occurs
- *
- * @specnote This constructor is public since JDK 1.4
- */
- public ServerSocket() throws IOException
- {
- if (factory != null)
- impl = factory.createSocketImpl();
- else
- impl = new PlainSocketImpl();
-
- impl.create(true);
- }
-
- /**
- * Creates a server socket and binds it to the specified port. If the
- * port number is 0, a random free port will be chosen. The pending
- * connection queue on this socket will be set to 50.
- *
- * @param port The port number 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 ServerSocket(int port) throws IOException
- {
- this(port, 50);
- }
-
- /**
- * Creates a server socket and binds it to the specified port. If the
- * port number is 0, a random free port will be chosen. The pending
- * connection queue on this socket will be set to the value passed as
- * arg2.
- *
- * @param port The port number to bind to
- * @param backlog The length of the pending connection queue
- *
- * @exception IOException If an error occurs
- * @exception SecurityException If a security manager exists and its
- * checkListen method doesn't allow the operation
- */
- public ServerSocket(int port, int backlog) throws IOException
- {
- this(port, backlog, null);
- }
-
- /**
- * Creates a server socket and binds it to the specified port. If the
- * port number is 0, a random free port will be chosen. The pending
- * connection queue on this socket will be set to the value passed as
- * backlog. The third argument specifies a particular local address to
- * bind t or null to bind to all local address.
- *
- * @param port The port number to bind to
- * @param backlog The length of the pending connection queue
- * @param bindAddr The address to bind to, or null to bind to all addresses
- *
- * @exception IOException If an error occurs
- * @exception SecurityException If a security manager exists and its
- * checkListen method doesn't allow the operation
- *
- * @since 1.1
- */
- public ServerSocket(int port, int backlog, InetAddress bindAddr)
- throws IOException
- {
- this();
-
- // bind/listen socket
- bind(new InetSocketAddress(bindAddr, port), backlog);
- }
-
- /**
- * Binds the server socket to a specified socket address
- *
- * @param endpoint The socket address to bind to
- *
- * @exception IOException If an error occurs
- * @exception IllegalArgumentException If address type is not supported
- * @exception SecurityException If a security manager exists and its
- * checkListen method doesn't allow the operation
- *
- * @since 1.4
- */
- public void bind(SocketAddress endpoint) throws IOException
- {
- bind(endpoint, 50);
- }
-
- /**
- * Binds the server socket to a specified socket address
- *
- * @param endpoint The socket address to bind to
- * @param backlog The length of the pending connection queue
- *
- * @exception IOException If an error occurs
- * @exception IllegalArgumentException If address type is not supported
- * @exception SecurityException If a security manager exists and its
- * checkListen method doesn't allow the operation
- *
- * @since 1.4
- */
- public void bind(SocketAddress endpoint, int backlog)
- throws IOException
- {
- if (isClosed())
- throw new SocketException("ServerSocket is closed");
-
- if (! (endpoint instanceof InetSocketAddress))
- throw new IllegalArgumentException("Address type not supported");
-
- InetSocketAddress tmp = (InetSocketAddress) endpoint;
-
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkListen(tmp.getPort());
-
- InetAddress addr = tmp.getAddress();
-
- // Initialize addr with 0.0.0.0.
- if (addr == null)
- addr = InetAddress.ANY_IF;
-
- try
- {
- impl.bind(addr, tmp.getPort());
- impl.listen(backlog);
- bound = true;
- }
- catch (IOException exception)
- {
- close();
- throw exception;
- }
- catch (RuntimeException exception)
- {
- close();
- throw exception;
- }
- catch (Error error)
- {
- close();
- throw error;
- }
- }
-
- /**
- * This method returns the local address to which this socket is bound
- *
- * @return The socket's local address
- */
- public InetAddress getInetAddress()
- {
- if (! isBound())
- return null;
-
- try
- {
- return (InetAddress) impl.getOption(SocketOptions.SO_BINDADDR);
- }
- catch (SocketException e)
- {
- // This never happens as we are bound.
- return null;
- }
- }
-
- /**
- * This method returns the local port number to which this socket is bound
- *
- * @return The socket's port number
- */
- public int getLocalPort()
- {
- if (! isBound())
- return -1;
-
- return impl.getLocalPort();
- }
-
- /**
- * Returns the local socket address
- *
- * @return the local socket address, null if not bound
- *
- * @since 1.4
- */
- public SocketAddress getLocalSocketAddress()
- {
- if (! isBound())
- return null;
-
- return new InetSocketAddress(getInetAddress(), getLocalPort());
- }
-
- /**
- * Accepts a new connection and returns a connected <code>Socket</code>
- * instance representing that connection. This method will block until a
- * connection is available.
- *
- * @return socket object for the just accepted connection
- *
- * @exception IOException If an error occurs
- * @exception SecurityException If a security manager exists and its
- * checkListen method doesn't allow the operation
- * @exception IllegalBlockingModeException If this socket has an associated
- * channel, and the channel is in non-blocking mode
- * @exception SocketTimeoutException If a timeout was previously set with
- * setSoTimeout and the timeout has been reached
- */
- public Socket accept() throws IOException
- {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkListen(impl.getLocalPort());
-
- Socket socket = new Socket();
-
- try
- {
- implAccept(socket);
- }
- catch (IOException e)
- {
- try
- {
- socket.close();
- }
- catch (IOException e2)
- {
- // Ignore.
- }
-
- throw e;
- }
-
- return socket;
- }
-
- /**
- * This protected method is used to help subclasses override
- * <code>ServerSocket.accept()</code>. The passed in socket will be
- * connected when this method returns.
- *
- * @param socket The socket that is used for the accepted connection
- *
- * @exception IOException If an error occurs
- * @exception IllegalBlockingModeException If this socket has an associated
- * channel, and the channel is in non-blocking mode
- *
- * @since 1.1
- */
- protected final void implAccept(Socket socket) throws IOException
- {
- if (isClosed())
- throw new SocketException("ServerSocket is closed");
-
- // The Sun spec says that if we have an associated channel and
- // it is in non-blocking mode, we throw an IllegalBlockingModeException.
- // However, in our implementation if the channel itself initiated this
- // operation, then we must honor it regardless of its blocking mode.
- if (getChannel() != null && ! getChannel().isBlocking()
- && ! ((PlainSocketImpl) getImpl()).isInChannelOperation())
- throw new IllegalBlockingModeException();
-
- impl.accept(socket.impl);
- socket.implCreated = true;
- }
-
- /**
- * Closes this socket and stops listening for connections
- *
- * @exception IOException If an error occurs
- */
- public void close() throws IOException
- {
- if (isClosed())
- return;
-
- impl.close();
- impl = null;
- bound = false;
-
- if (getChannel() != null)
- getChannel().close();
- }
-
- /**
- * Returns the unique <code>ServerSocketChannel</code> object
- * associated with this socket, if any.
- *
- * <p>The socket only has a <code>ServerSocketChannel</code> if its created
- * by <code>ServerSocketChannel.open()</code>.</p>
- *
- * @return the associated socket channel, null if none exists
- *
- * @since 1.4
- */
- public ServerSocketChannel getChannel()
- {
- return null;
- }
-
- /**
- * Returns true when the socket is bound, otherwise false
- *
- * @return true if socket is bound, false otherwise
- *
- * @since 1.4
- */
- public boolean isBound()
- {
- return bound;
- }
-
- /**
- * Returns true if the socket is closed, otherwise false
- *
- * @return true if socket is closed, false otherwise
- *
- * @since 1.4
- */
- public boolean isClosed()
- {
- return impl == null;
- }
-
- /**
- * Sets the value of SO_TIMEOUT. A value of 0 implies that SO_TIMEOUT is
- * disabled (ie, operations never time out). This is the number of
- * milliseconds a socket operation can block before an
- * InterruptedIOException is thrown.
- *
- * @param timeout The new SO_TIMEOUT value
- *
- * @exception SocketException If an error occurs
- *
- * @since 1.1
- */
- public void setSoTimeout(int timeout) throws SocketException
- {
- if (isClosed())
- throw new SocketException("ServerSocket is closed");
-
- if (timeout < 0)
- throw new IllegalArgumentException("SO_TIMEOUT value must be >= 0");
-
- impl.setOption(SocketOptions.SO_TIMEOUT, new Integer(timeout));
- }
-
- /**
- * Retrieves the current value of the SO_TIMEOUT setting. A value of 0
- * implies that SO_TIMEOUT is disabled (ie, operations never time out).
- * This is the number of milliseconds a socket operation can block before
- * an InterruptedIOException is thrown.
- *
- * @return The value of SO_TIMEOUT
- *
- * @exception IOException If an error occurs
- *
- * @since 1.1
- */
- public int getSoTimeout() throws IOException
- {
- if (isClosed())
- throw new SocketException("ServerSocket is closed");
-
- Object timeout = impl.getOption(SocketOptions.SO_TIMEOUT);
-
- if (! (timeout instanceof Integer))
- throw new IOException("Internal Error");
-
- return ((Integer) timeout).intValue();
- }
-
- /**
- * Enables/Disables the SO_REUSEADDR option
- *
- * @param on true if SO_REUSEADDR should be enabled, false otherwise
- *
- * @exception SocketException If an error occurs
- *
- * @since 1.4
- */
- public void setReuseAddress(boolean on) throws SocketException
- {
- if (isClosed())
- throw new SocketException("ServerSocket is closed");
-
- impl.setOption(SocketOptions.SO_REUSEADDR, Boolean.valueOf(on));
- }
-
- /**
- * Checks if the SO_REUSEADDR option is enabled
- *
- * @return true if SO_REUSEADDR is set, false otherwise
- *
- * @exception SocketException If an error occurs
- *
- * @since 1.4
- */
- public boolean getReuseAddress() throws SocketException
- {
- if (isClosed())
- throw new SocketException("ServerSocket is closed");
-
- Object reuseaddr = impl.getOption(SocketOptions.SO_REUSEADDR);
-
- if (! (reuseaddr instanceof Boolean))
- throw new SocketException("Internal Error");
-
- return ((Boolean) reuseaddr).booleanValue();
- }
-
- /**
- * This method sets the value for the system level socket option
- * SO_RCVBUF to the specified value. Note that valid values for this
- * option are specific to a given operating system.
- *
- * @param size The new receive buffer size.
- *
- * @exception SocketException If an error occurs or Socket is not connected
- * @exception IllegalArgumentException If size is 0 or negative
- *
- * @since 1.4
- */
- public void setReceiveBufferSize(int size) throws SocketException
- {
- if (isClosed())
- throw new SocketException("ServerSocket is closed");
-
- if (size <= 0)
- throw new IllegalArgumentException("SO_RCVBUF value must be > 0");
-
- impl.setOption(SocketOptions.SO_RCVBUF, new Integer(size));
- }
-
- /**
- * This method returns the value of the system level socket option
- * SO_RCVBUF, which is used by the operating system to tune buffer
- * sizes for data transfers.
- *
- * @return The receive buffer size.
- *
- * @exception SocketException If an error occurs or Socket is not connected
- *
- * @since 1.4
- */
- public int getReceiveBufferSize() throws SocketException
- {
- if (isClosed())
- throw new SocketException("ServerSocket is closed");
-
- Object buf = impl.getOption(SocketOptions.SO_RCVBUF);
-
- if (! (buf instanceof Integer))
- throw new SocketException("Internal Error: Unexpected type");
-
- return ((Integer) buf).intValue();
- }
-
- /**
- * Returns the value of this socket as a <code>String</code>.
- *
- * @return This socket represented as a <code>String</code>.
- */
- public String toString()
- {
- if (! isBound())
- return "ServerSocket[unbound]";
-
- return ("ServerSocket[addr=" + getInetAddress() + ",port="
- + impl.getPort() + ",localport=" + impl.getLocalPort() + "]");
- }
-
- /**
- * Sets the <code>SocketImplFactory</code> for all
- * <code>ServerSocket</code>'s. This may only be done
- * once per virtual machine. Subsequent attempts will generate an
- * exception. Note that a <code>SecurityManager</code> check is made prior
- * to setting the factory. If insufficient privileges exist to set the
- * factory, an exception will be thrown
- *
- * @param fac the factory to set
- *
- * @exception SecurityException If this operation is not allowed by the
- * <code>SecurityManager</code>.
- * @exception SocketException If the factory object is already defined
- * @exception IOException If any other error occurs
- */
- public static synchronized void setSocketFactory(SocketImplFactory fac)
- throws IOException
- {
- factory = fac;
- }
-}
diff --git a/libjava/java/net/URLClassLoader.java b/libjava/java/net/URLClassLoader.java
index dd947cb..5bb0337 100644
--- a/libjava/java/net/URLClassLoader.java
+++ b/libjava/java/net/URLClassLoader.java
@@ -248,12 +248,10 @@ public class URLClassLoader extends SecureClassLoader
abstract static class Resource
{
final URLLoader loader;
- final String name;
- Resource(URLLoader loader, String name)
+ Resource(URLLoader loader)
{
this.loader = loader;
- this.name = name;
}
/**
@@ -404,11 +402,13 @@ public class URLClassLoader extends SecureClassLoader
static final class JarURLResource extends Resource
{
private final JarEntry entry;
+ private final String name;
JarURLResource(JarURLLoader loader, String name, JarEntry entry)
{
- super(loader, name);
+ super(loader);
this.entry = entry;
+ this.name = name;
}
InputStream getInputStream() throws IOException
@@ -509,7 +509,7 @@ public class URLClassLoader extends SecureClassLoader
RemoteResource(RemoteURLLoader loader, String name, URL url,
InputStream stream, int length)
{
- super(loader, name);
+ super(loader);
this.url = url;
this.stream = stream;
this.length = length;
@@ -561,15 +561,15 @@ public class URLClassLoader extends SecureClassLoader
URL url = helper.findResource(name);
if (url == null)
return null;
- return new SoResource(this, name, url);
+ return new SoResource(this, url);
}
}
final static class SoResource extends Resource
{
- SoResource(SoURLLoader loader, String name, URL url)
+ SoResource(SoURLLoader loader, URL url)
{
- super(loader, name);
+ super(loader);
this.url = url;
}
@@ -614,7 +614,7 @@ public class URLClassLoader extends SecureClassLoader
{
File file = new File(dir, name).getCanonicalFile();
if (file.exists() && !file.isDirectory())
- return new FileResource(this, file.getPath(), file);
+ return new FileResource(this, file);
}
catch (IOException e)
{
@@ -628,9 +628,9 @@ public class URLClassLoader extends SecureClassLoader
{
final File file;
- FileResource(FileURLLoader loader, String name, File file)
+ FileResource(FileURLLoader loader, File file)
{
- super(loader, name);
+ super(loader);
this.file = file;
}
@@ -673,8 +673,7 @@ public class URLClassLoader extends SecureClassLoader
{
try
{
- return new URL(loader.baseURL, name,
- loader.classloader.getURLStreamHandler("file"));
+ return file.toURL();
}
catch (MalformedURLException e)
{
@@ -711,12 +710,14 @@ public class URLClassLoader extends SecureClassLoader
static final class CoreResource extends Resource
{
- final Core core;
+ private final Core core;
+ private final String name;
CoreResource(CoreURLLoader loader, String name, Core core)
{
- super(loader, name);
+ super(loader);
this.core = core;
+ this.name = name;
}
InputStream getInputStream() throws IOException
@@ -755,10 +756,10 @@ public class URLClassLoader extends SecureClassLoader
* in the order given to the URLClassLoader which uses these URLs to
* load classes and resources (after using the default parent ClassLoader).
*
- * @exception SecurityException if the SecurityManager disallows the
- * creation of a ClassLoader.
* @param urls Locations that should be searched by this ClassLoader when
* resolving Classes or Resources.
+ * @exception SecurityException if the SecurityManager disallows the
+ * creation of a ClassLoader.
* @see SecureClassLoader
*/
public URLClassLoader(URL[] urls) throws SecurityException
@@ -770,25 +771,6 @@ public class URLClassLoader extends SecureClassLoader
}
/**
- * Private constructor used by the static
- * <code>newInstance(URL[])</code> method. Creates an
- * <code>URLClassLoader</code> without any <code>URL</code>s
- * yet. This is used to bypass the normal security check for
- * creating classloaders, but remembers the security context which
- * will be used when defining classes. The <code>URL</code>s to
- * load from must be added by the <code>newInstance()</code> method
- * in the security context of the caller.
- *
- * @param securityContext the security context of the unprivileged code.
- */
- private URLClassLoader(AccessControlContext securityContext)
- {
- super();
- this.factory = null;
- this.securityContext = securityContext;
- }
-
- /**
* Creates a <code>URLClassLoader</code> that gets classes from the supplied
* <code>URL</code>s.
* To determine if this classloader may be created the constructor of
@@ -796,13 +778,13 @@ public class URLClassLoader extends SecureClassLoader
* can throw a SecurityException. Then the supplied URLs are added
* in the order given to the URLClassLoader which uses these URLs to
* load classes and resources (after using the supplied parent ClassLoader).
- * @exception SecurityException if the SecurityManager disallows the
- * creation of a ClassLoader.
- * @exception SecurityException
* @param urls Locations that should be searched by this ClassLoader when
* resolving Classes or Resources.
* @param parent The parent class loader used before trying this class
* loader.
+ * @exception SecurityException if the SecurityManager disallows the
+ * creation of a ClassLoader.
+ * @exception SecurityException
* @see SecureClassLoader
*/
public URLClassLoader(URL[] urls, ClassLoader parent)
@@ -844,14 +826,14 @@ public class URLClassLoader extends SecureClassLoader
* load classes and resources (after using the supplied parent ClassLoader).
* It will use the supplied <CODE>URLStreamHandlerFactory</CODE> to get the
* protocol handlers of the supplied URLs.
- * @exception SecurityException if the SecurityManager disallows the
- * creation of a ClassLoader.
- * @exception SecurityException
* @param urls Locations that should be searched by this ClassLoader when
* resolving Classes or Resources.
* @param parent The parent class loader used before trying this class
* loader.
* @param factory Used to get the protocol handler for the URLs.
+ * @exception SecurityException if the SecurityManager disallows the
+ * creation of a ClassLoader.
+ * @exception SecurityException
* @see SecureClassLoader
*/
public URLClassLoader(URL[] urls, ClassLoader parent,
@@ -938,13 +920,21 @@ public class URLClassLoader extends SecureClassLoader
}
/**
- * Adds an array of new locations to the end of the internal URL store.
+ * Adds an array of new locations to the end of the internal URL
+ * store. Called from the the constructors. Should not call to the
+ * protected addURL() method since that can be overridden and
+ * subclasses are not yet in a good state at this point.
+ * jboss 4.0.3 for example depends on this.
+ *
* @param newUrls the locations to add
*/
private void addURLs(URL[] newUrls)
{
for (int i = 0; i < newUrls.length; i++)
- addURL(newUrls[i]);
+ {
+ urls.add(newUrls[i]);
+ addURLImpl(newUrls[i]);
+ }
}
/**
@@ -969,13 +959,13 @@ public class URLClassLoader extends SecureClassLoader
* package is sealed. If the Manifest indicates that the package is sealed
* then the Package will be sealed with respect to the supplied URL.
*
- * @exception IllegalArgumentException If this package name already exists
- * in this class loader
* @param name The name of the package
* @param manifest The manifest describing the specification,
* implementation and sealing details of the package
* @param url the code source url to seal the package
* @return the defined Package
+ * @throws IllegalArgumentException If this package name already exists
+ * in this class loader
*/
protected Package definePackage(String name, Manifest manifest, URL url)
throws IllegalArgumentException
@@ -1062,40 +1052,47 @@ public class URLClassLoader extends SecureClassLoader
// construct the class (and watch out for those nasty IOExceptions)
try
{
- byte[] data;
- InputStream in = resource.getInputStream();
- int length = resource.getLength();
- if (length != -1)
+ byte[] data;
+ InputStream in = resource.getInputStream();
+ try
{
- // We know the length of the data.
- // Just try to read it in all at once
- data = new byte[length];
- int pos = 0;
- while (length - pos > 0)
+ int length = resource.getLength();
+ if (length != -1)
{
- int len = in.read(data, pos, length - pos);
- if (len == -1)
- throw new EOFException("Not enough data reading from: "
- + in);
- pos += len;
+ // We know the length of the data.
+ // Just try to read it in all at once
+ data = new byte[length];
+ int pos = 0;
+ while (length - pos > 0)
+ {
+ int len = in.read(data, pos, length - pos);
+ if (len == -1)
+ throw new EOFException("Not enough data reading from: "
+ + in);
+ pos += len;
+ }
}
- }
- else
- {
- // We don't know the data length.
- // Have to read it in chunks.
- ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
- byte[] b = new byte[4096];
- int l = 0;
- while (l != -1)
+ else
{
- l = in.read(b);
- if (l != -1)
- out.write(b, 0, l);
+ // We don't know the data length.
+ // Have to read it in chunks.
+ ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
+ byte[] b = new byte[4096];
+ int l = 0;
+ while (l != -1)
+ {
+ l = in.read(b);
+ if (l != -1)
+ out.write(b, 0, l);
+ }
+ data = out.toByteArray();
}
- data = out.toByteArray();
- }
- final byte[] classData = data;
+ }
+ finally
+ {
+ in.close();
+ }
+ final byte[] classData = data;
// Now get the CodeSource
final CodeSource source = resource.getCodeSource();
@@ -1136,7 +1133,11 @@ public class URLClassLoader extends SecureClassLoader
else
result = defineClass(className, classData, 0, classData.length, source);
- super.setSigners(result, resource.getCertificates());
+ // Avoid NullPointerExceptions.
+ Certificate[] resourceCertificates = resource.getCertificates();
+ if(resourceCertificates != null)
+ super.setSigners(result, resourceCertificates);
+
return result;
}
catch (IOException ioe)
@@ -1252,11 +1253,11 @@ public class URLClassLoader extends SecureClassLoader
/**
* Finds all the resources with a particular name from all the locations.
*
- * @exception IOException when an error occurs accessing one of the
- * locations
* @param resourceName the name of the resource to lookup
* @return a (possible empty) enumeration of URLs where the resource can be
* found
+ * @exception IOException when an error occurs accessing one of the
+ * locations
*/
public Enumeration findResources(String resourceName)
throws IOException
@@ -1291,7 +1292,7 @@ public class URLClassLoader extends SecureClassLoader
*
* @param source The codesource that needs the permissions to be accessed
* @return the collection of permissions needed to access the code resource
- * @see java.security.SecureClassLoader#getPermissions()
+ * @see java.security.SecureClassLoader#getPermissions(CodeSource)
*/
protected PermissionCollection getPermissions(CodeSource source)
{
diff --git a/libjava/java/net/URLConnection.java b/libjava/java/net/URLConnection.java
index 55b9d66..b5e4cb0 100644
--- a/libjava/java/net/URLConnection.java
+++ b/libjava/java/net/URLConnection.java
@@ -539,7 +539,7 @@ public abstract class URLConnection
}
/**
- * Returns the value of a flag indicating whether or not input is going
+ * Sets the value of a flag indicating whether or not input is going
* 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.
*
@@ -569,7 +569,7 @@ public abstract class URLConnection
}
/**
- * Returns a boolean flag indicating whether or not output will be done
+ * Sets a boolean flag indicating whether or not output will be done
* on this connection. The default value is false, so this method can
* be used to override the default
*
@@ -860,7 +860,7 @@ public abstract class URLConnection
}
/**
- * Set's the ContentHandlerFactory for an application. This can be called
+ * Sets the ContentHandlerFactory for an application. This can be called
* once and only once. If it is called again, then an Error is thrown.
* Unlike for other set factory methods, this one does not do a security
* check prior to setting the factory.
@@ -956,7 +956,7 @@ public abstract class URLConnection
}
/**
- * This method set the <code>FileNameMap</code> object being used
+ * This method sets the <code>FileNameMap</code> object being used
* to decode MIME types by file extension.
*
* @param map The <code>FileNameMap</code>.
diff --git a/libjava/sources.am b/libjava/sources.am
index c78c986..ddf5c8d 100644
--- a/libjava/sources.am
+++ b/libjava/sources.am
@@ -976,9 +976,9 @@ gnu/java/net.list: $(gnu_java_net_source_files)
gnu_java_net_protocol_file_source_files = \
gnu/java/net/protocol/file/Connection.java \
-gnu/java/net/protocol/file/Handler.java
+classpath/gnu/java/net/protocol/file/Handler.java
-gnu_java_net_protocol_file_header_files = $(patsubst %.java,%.h,$(gnu_java_net_protocol_file_source_files))
+gnu_java_net_protocol_file_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_net_protocol_file_source_files)))
gnu/java/net/protocol/file.list: $(gnu_java_net_protocol_file_source_files)
@$(mkinstalldirs) $(dir $@)
@@ -3009,7 +3009,7 @@ classpath/java/net/NoRouteToHostException.java \
classpath/java/net/PasswordAuthentication.java \
classpath/java/net/PortUnreachableException.java \
classpath/java/net/ProtocolException.java \
-java/net/ServerSocket.java \
+classpath/java/net/ServerSocket.java \
classpath/java/net/Socket.java \
classpath/java/net/SocketAddress.java \
classpath/java/net/SocketException.java \