test/com/sun/jdi/BadHandshakeTest.java

Print this page


   1 /*
   2  * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   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  */


  91     /*
  92      * Find a connector by name
  93      */
  94     private static Connector findConnector(String name) {
  95         List connectors = Bootstrap.virtualMachineManager().allConnectors();
  96         Iterator iter = connectors.iterator();
  97         while (iter.hasNext()) {
  98             Connector connector = (Connector)iter.next();
  99             if (connector.name().equals(name)) {
 100                 return connector;
 101             }
 102         }
 103         return null;
 104     }
 105 
 106     /*
 107      * Launch a server debuggee with the given address
 108      */
 109     private static Process launch(String address, String class_name) throws IOException {
 110         String exe =   System.getProperty("java.home")
 111                      + File.separator + "bin" + File.separator;
 112         String arch = System.getProperty("os.arch");
 113         String osname = System.getProperty("os.name");
 114         if (osname.equals("SunOS") && arch.equals("sparcv9")) {
 115             exe += "sparcv9/java";
 116         } else if (osname.equals("SunOS") && arch.equals("amd64")) {
 117             exe += "amd64/java";
 118         } else {
 119             exe += "java";
 120         }
 121         String cmd = exe + " " + VMConnection.getDebuggeeVMOptions() +
 122             " -agentlib:jdwp=transport=dt_socket" +
 123             ",server=y" + ",suspend=y" + ",address=" + address +
 124             " " + class_name;
 125 
 126         System.out.println("Starting: " + cmd);
 127 
 128         Process p = Runtime.getRuntime().exec(cmd);
 129 
 130         IOHandler.handle(p.getInputStream());
 131         IOHandler.handle(p.getErrorStream());
 132 
 133         return p;
 134     }
 135 
 136     /*
 137      * - pick a TCP port
 138      * - Launch a server debuggee: server=y,suspend=y,address=${port}
 139      * - run it to VM death
 140      * - verify we saw no error


   1 /*
   2  * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   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  */


  91     /*
  92      * Find a connector by name
  93      */
  94     private static Connector findConnector(String name) {
  95         List connectors = Bootstrap.virtualMachineManager().allConnectors();
  96         Iterator iter = connectors.iterator();
  97         while (iter.hasNext()) {
  98             Connector connector = (Connector)iter.next();
  99             if (connector.name().equals(name)) {
 100                 return connector;
 101             }
 102         }
 103         return null;
 104     }
 105 
 106     /*
 107      * Launch a server debuggee with the given address
 108      */
 109     private static Process launch(String address, String class_name) throws IOException {
 110         String exe =   System.getProperty("java.home")
 111                      + File.separator + "bin" + File.separator + "java";









 112         String cmd = exe + " " + VMConnection.getDebuggeeVMOptions() +
 113             " -agentlib:jdwp=transport=dt_socket" +
 114             ",server=y" + ",suspend=y" + ",address=" + address +
 115             " " + class_name;
 116 
 117         System.out.println("Starting: " + cmd);
 118 
 119         Process p = Runtime.getRuntime().exec(cmd);
 120 
 121         IOHandler.handle(p.getInputStream());
 122         IOHandler.handle(p.getErrorStream());
 123 
 124         return p;
 125     }
 126 
 127     /*
 128      * - pick a TCP port
 129      * - Launch a server debuggee: server=y,suspend=y,address=${port}
 130      * - run it to VM death
 131      * - verify we saw no error