aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/net/PlainSocketImpl.java
diff options
context:
space:
mode:
authorJeff Sturm <jsturm@one-point.com>2002-03-28 02:08:36 +0000
committerJeff Sturm <jsturm@gcc.gnu.org>2002-03-28 02:08:36 +0000
commit47d0866c79c04d8d86ce3d1eff9dda7899179c4b (patch)
tree51916c05d0f82e2a643314cf640e5e7582d021d9 /libjava/java/net/PlainSocketImpl.java
parent1b58660a9d302afe516eca5023066585ae6ceb85 (diff)
downloadgcc-47d0866c79c04d8d86ce3d1eff9dda7899179c4b.zip
gcc-47d0866c79c04d8d86ce3d1eff9dda7899179c4b.tar.gz
gcc-47d0866c79c04d8d86ce3d1eff9dda7899179c4b.tar.bz2
* 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
Diffstat (limited to 'libjava/java/net/PlainSocketImpl.java')
-rw-r--r--libjava/java/net/PlainSocketImpl.java21
1 files changed, 16 insertions, 5 deletions
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:
- * <pre>
- * fd = new FileDescriptor (fnum);
- * </pre>
- *
* 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.
*/