Initial load
diff --git a/test/java/net/ServerSocket/AcceptCauseFileDescriptorLeak.java b/test/java/net/ServerSocket/AcceptCauseFileDescriptorLeak.java
new file mode 100644
index 0000000..d5463f0
--- /dev/null
+++ b/test/java/net/ServerSocket/AcceptCauseFileDescriptorLeak.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @summary configuring unconnected Socket before passing to implAccept can cause fd leak
+ * @bug 6368984
+ * @author Edward Wang
+ */
+
+import java.io.*;
+import java.net.*;
+
+public class AcceptCauseFileDescriptorLeak {
+    private static final int REPS = 1000;
+
+    public static void main(String[] args) throws Exception {
+        final ServerSocket ss = new ServerSocket(0) {
+            public Socket accept() throws IOException {
+                Socket s = new Socket() { };
+                s.setSoTimeout(10000);
+                implAccept(s);
+                return s;
+            }
+        };
+        Thread t = new Thread(new Runnable() {
+            public void run() {
+                try {
+                    for (int i = 0; i < REPS; i++) {
+                        (new Socket("localhost", ss.getLocalPort())).close();
+                    }
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        });
+        t.start();
+        for (int i = 0; i < REPS; i++) {
+            ss.accept().close();
+        }
+        ss.close();
+        t.join();
+
+        //
+        // The threshold 20 below is a little arbitrary. The point here is that
+        // the remaining open file descriptors should be constant independent
+        // of REPS.
+        //
+        if (countOpenFD() > 20) {
+            throw new RuntimeException("File descriptor leak detected.");
+        }
+    }
+
+
+    /*
+     * Actually, this approach to count open file descriptors only
+     * works for Solaris/Linux. On Windows platform, this method
+     * will simply return zero. So the test will always be passed
+     * on Windows, too.
+     */
+    private static int countOpenFD() {
+        File dirOfFD = new File("/proc/self/fd");
+        File[] fds = dirOfFD.listFiles();
+
+        if (fds != null)
+            return fds.length;
+        else
+            return 0;
+    }
+}
diff --git a/test/java/net/ServerSocket/TestAfterClose.java b/test/java/net/ServerSocket/TestAfterClose.java
new file mode 100644
index 0000000..ac99d14
--- /dev/null
+++ b/test/java/net/ServerSocket/TestAfterClose.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6505016
+ * @summary Socket spec should clarify what getInetAddress/getPort/etc return after the Socket is closed
+ */
+
+import java.net.*;
+import java.io.*;
+
+public class TestAfterClose
+{
+    static int failCount;
+
+    public static void main(String[] args) {
+        try {
+            ServerSocket ss = new ServerSocket(0, 0, null);
+            test(ss);
+        } catch (IOException ioe) {
+            ioe.printStackTrace();
+        }
+
+        if (failCount > 0)
+            throw new RuntimeException("Failed: failcount = " + failCount);
+
+    }
+
+    static void test(ServerSocket ss) throws IOException {
+        //Before Close
+        InetAddress ssInetAddress = ss.getInetAddress();
+        int ssLocalPort = ss.getLocalPort();
+        SocketAddress ssLocalSocketAddress = ss.getLocalSocketAddress();
+
+        //After Close
+        ss.close();
+
+        if (ssLocalPort != ss.getLocalPort()) {
+            System.out.println("ServerSocket.getLocalPort failed");
+            failCount++;
+        }
+
+        if (!ss.getInetAddress().equals(ssInetAddress)) {
+            System.out.println("ServerSocket.getInetAddress failed");
+            failCount++;
+        }
+
+        if (!ss.getLocalSocketAddress().equals(ssLocalSocketAddress)) {
+            System.out.println("ServerSocket.getLocalSocketAddress failed");
+            failCount++;
+        }
+
+        if (!ss.isBound()) {
+            System.out.println("ServerSocket.isBound failed");
+            failCount++;
+        }
+
+    }
+}
diff --git a/test/java/net/ServerSocket/ThreadStop.java b/test/java/net/ServerSocket/ThreadStop.java
new file mode 100644
index 0000000..6f0b795
--- /dev/null
+++ b/test/java/net/ServerSocket/ThreadStop.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2002 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 4680160
+ * @summary The deprecated Thread.stop exposes un-checked JNI calls
+ *          that result in crashes when NULL is passed into subsequent
+ *          JNI calls.
+ */
+
+import java.net.*;
+import java.io.IOException;
+
+public class ThreadStop {
+
+    static class Server implements Runnable {
+
+        ServerSocket ss;
+
+        Server() throws IOException {
+            ss = new ServerSocket(0);
+        }
+
+        public int localPort() {
+            return ss.getLocalPort();
+        }
+
+
+        public void run() {
+            try {
+                Socket s = ss.accept();
+            } catch (IOException ioe) {
+            } catch (ThreadDeath x) {
+            } finally {
+                try {
+                    ss.close();
+                } catch (IOException x) { }
+            }
+        }
+    }
+
+    public static void main(String args[]) throws Exception {
+
+        // start a server
+        Server svr = new Server();
+        Thread thr = new Thread(svr);
+        thr.start();
+
+        // give server time to block in ServerSocket.accept()
+        Thread.currentThread().sleep(2000);
+
+        // "stop" the thread
+        thr.stop();
+
+        // give thread time to stop
+        Thread.currentThread().sleep(2000);
+
+        // it's platform specific if Thread.stop interrupts the
+        // thread - on Linux/Windows most likely that thread is
+        // still in accept() so we connect to server which causes
+        // it to unblock and do JNI-stuff with a pending exception
+
+        try {
+            Socket s = new Socket("localhost", svr.localPort());
+        } catch (IOException ioe) { }
+
+    }
+
+}