7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @summary Smoke test for JDWP hardening
27 * @library /lib/testlibrary
28 * @library /test/lib
29 * @run driver BasicJDWPConnectionTest
30 */
31
32 import java.io.IOException;
33 import java.io.BufferedReader;
34 import java.io.InputStreamReader;
35
36 import java.net.Socket;
37 import java.net.SocketException;
38
39 import jdk.test.lib.apps.LingeredApp;
40 import jdk.testlibrary.Utils;
41
42 import java.util.ArrayList;
43 import java.util.List;
44
45
46 public class BasicJDWPConnectionTest {
47
48 public static int handshake(int port) throws IOException {
49 // Connect to the debuggee and handshake
50 int res = -1;
51 Socket s = null;
52 try {
53 s = new Socket("localhost", port);
54 s.getOutputStream().write("JDWP-Handshake".getBytes("UTF-8"));
55 byte[] buffer = new byte[24];
56 res = s.getInputStream().read(buffer);
57 }
58 catch (SocketException ex) {
59 // pass
60 } finally {
|
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @summary Smoke test for JDWP hardening
27 * @library /test/lib
28 * @run driver BasicJDWPConnectionTest
29 */
30
31 import java.io.IOException;
32 import java.io.BufferedReader;
33 import java.io.InputStreamReader;
34
35 import java.net.Socket;
36 import java.net.SocketException;
37
38 import jdk.test.lib.apps.LingeredApp;
39 import jdk.test.lib.Utils;
40
41 import java.util.ArrayList;
42 import java.util.List;
43
44
45 public class BasicJDWPConnectionTest {
46
47 public static int handshake(int port) throws IOException {
48 // Connect to the debuggee and handshake
49 int res = -1;
50 Socket s = null;
51 try {
52 s = new Socket("localhost", port);
53 s.getOutputStream().write("JDWP-Handshake".getBytes("UTF-8"));
54 byte[] buffer = new byte[24];
55 res = s.getInputStream().read(buffer);
56 }
57 catch (SocketException ex) {
58 // pass
59 } finally {
|