summaryrefslogtreecommitdiff
path: root/libjava/java/net/PlainDatagramSocketImpl.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/PlainDatagramSocketImpl.java
parent1b58660a9d302afe516eca5023066585ae6ceb85 (diff)
* 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/PlainDatagramSocketImpl.java')
-rw-r--r--libjava/java/net/PlainDatagramSocketImpl.java32
1 files changed, 11 insertions, 21 deletions
diff --git a/libjava/java/net/PlainDatagramSocketImpl.java b/libjava/java/net/PlainDatagramSocketImpl.java
index 7076ccf31b1..55ea468dadc 100644
--- a/libjava/java/net/PlainDatagramSocketImpl.java
+++ b/libjava/java/net/PlainDatagramSocketImpl.java
@@ -67,27 +67,7 @@ class PlainDatagramSocketImpl extends DatagramSocketImpl
public native Object getOption(int optID) throws SocketException;
private native void mcastGrp(InetAddress inetaddr, boolean join)
throws IOException;
-
- protected void close()
- {
- // FIXME: The close method in each of the DatagramSocket* classes does
- // not throw an IOException. The issue is that FileDescriptor.close()
- // in natFileDescriptorPosix.cc can throw one, so we have to catch
- // it here. It seems that FileDescriptor.close is properly throwing
- // the IOException on errors since many of the java.io classes depend
- // on that. This probably requires a bit more research but for now,
- // we'll catch the IOException here.
- try
- {
- if (fd.valid())
- fd.close();
- }
- catch (IOException e)
- {
- System.err.println("PlainDatagramSocketImpl.close: Error closing - " +
- e.getMessage());
- }
- }
+ protected native void close();
// Deprecated in JDK 1.2.
protected byte getTTL() throws IOException
@@ -110,4 +90,14 @@ class PlainDatagramSocketImpl extends DatagramSocketImpl
{
mcastGrp(inetaddr, false);
}
+
+ protected void finalize() throws Throwable
+ {
+ synchronized (this)
+ {
+ if (fnum != -1)
+ close();
+ }
+ super.finalize();
+ }
}