test/com/sun/jdi/DoubleAgentTest.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  */


  73                         break;
  74                     }
  75                     String s = new String(b, 0, n, "UTF-8");
  76                     System.out.print(s);
  77                     synchronized(outputText) {
  78                         outputText += s;
  79                     }
  80                 }
  81             } catch (IOException ioe) {
  82                 ioe.printStackTrace();
  83             }
  84         }
  85 
  86     }
  87 
  88     /*
  89      * Launch a server debuggee with the given address
  90      */
  91     private static Process launch(String address, String class_name) throws IOException {
  92         String exe =   System.getProperty("java.home")
  93                      + File.separator + "bin" + File.separator;
  94         String arch = System.getProperty("os.arch");
  95         String osname = System.getProperty("os.name");
  96         if (osname.equals("SunOS") && arch.equals("sparcv9")) {
  97             exe += "sparcv9/java";
  98         } else if (osname.equals("SunOS") && arch.equals("amd64")) {
  99             exe += "amd64/java";
 100         } else {
 101             exe += "java";
 102         }
 103         String jdwpOption = "-agentlib:jdwp=transport=dt_socket"
 104                          + ",server=y" + ",suspend=y" + ",address=" + address;
 105         String cmd = exe + " " + VMConnection.getDebuggeeVMOptions()
 106                          + " " + jdwpOption
 107                          + " " + jdwpOption
 108                          + " " + class_name;
 109 
 110         System.out.println("Starting: " + cmd);
 111 
 112         Process p = Runtime.getRuntime().exec(cmd);
 113 
 114         return p;
 115     }
 116 
 117     /*
 118      * - pick a TCP port
 119      * - Launch a server debuggee that should fail
 120      * - verify we saw error
 121      */
 122     public static void main(String args[]) throws Exception {


   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  */


  73                         break;
  74                     }
  75                     String s = new String(b, 0, n, "UTF-8");
  76                     System.out.print(s);
  77                     synchronized(outputText) {
  78                         outputText += s;
  79                     }
  80                 }
  81             } catch (IOException ioe) {
  82                 ioe.printStackTrace();
  83             }
  84         }
  85 
  86     }
  87 
  88     /*
  89      * Launch a server debuggee with the given address
  90      */
  91     private static Process launch(String address, String class_name) throws IOException {
  92         String exe =   System.getProperty("java.home")
  93                      + File.separator + "bin" + File.separator + "java";









  94         String jdwpOption = "-agentlib:jdwp=transport=dt_socket"
  95                          + ",server=y" + ",suspend=y" + ",address=" + address;
  96         String cmd = exe + " " + VMConnection.getDebuggeeVMOptions()
  97                          + " " + jdwpOption
  98                          + " " + jdwpOption
  99                          + " " + class_name;
 100 
 101         System.out.println("Starting: " + cmd);
 102 
 103         Process p = Runtime.getRuntime().exec(cmd);
 104 
 105         return p;
 106     }
 107 
 108     /*
 109      * - pick a TCP port
 110      * - Launch a server debuggee that should fail
 111      * - verify we saw error
 112      */
 113     public static void main(String args[]) throws Exception {