From 47d0866c79c04d8d86ce3d1eff9dda7899179c4b Mon Sep 17 00:00:00 2001 From: Jeff Sturm Date: Thu, 28 Mar 2002 02:08:36 +0000 Subject: * java/net/PlainDatagramSocketImpl.java (close): Use native implementation. (finalize): New method. * java/net/PlainSocketImpl.java (finalize): New method. * java/net/natPlainDatagramSocketImpl.cc (java/io/FileDescriptor.h): Don't include. (close): Implement method here. (create): Don't assign fd. * java/net/natPlainSocketImpl.cc (java/io/FileDescriptor.h): Don't include. (create): Don't assign fd. (accept): Likewise. (close): Synchronize. From-SVN: r51492 --- libjava/java/net/PlainSocketImpl.java | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'libjava/java/net/PlainSocketImpl.java') diff --git a/libjava/java/net/PlainSocketImpl.java b/libjava/java/net/PlainSocketImpl.java index 81df487..354d652 100644 --- a/libjava/java/net/PlainSocketImpl.java +++ b/libjava/java/net/PlainSocketImpl.java @@ -39,11 +39,6 @@ class PlainSocketImpl extends SocketImpl * This is used for reads and writes to/from the socket and * to close it. * - * {@link SocketImpl#fd} is created from this like so: - *
-   *   fd = new FileDescriptor (fnum);
-   * 
- * * When the socket is closed this is reset to -1. */ int fnum = -1; @@ -108,6 +103,22 @@ class PlainSocketImpl extends SocketImpl private native void write(byte[] buffer, int offset, int count) throws IOException; + protected void finalize() throws Throwable + { + synchronized (this) + { + if (fnum != -1) + try + { + close(); + } + catch (IOException ex) + { + // ignore + } + } + super.finalize(); + } /** @return the input stream attached to the socket. */ -- cgit v1.1