test/demo/jvmti/DemoRun.java

Print this page




 108     {
 109         runit(class_name, null);
 110     }
 111 
 112     /*
 113      * Execute a process with an -agentpath or -agentlib command option
 114      *    plus any set of other java options.
 115      */
 116     public void runit(String class_name, String vm_options[])
 117     {
 118         String jre_home  = System.getProperty("java.home");
 119         String sdk_home  = (jre_home.endsWith("jre") ?
 120                             (jre_home + File.separator + "..") :
 121                             jre_home );
 122         String cdir      = System.getProperty("test.classes", ".");
 123         String os_arch   = System.getProperty("os.arch");
 124         String os_name   = System.getProperty("os.name");
 125         String libprefix = os_name.contains("Windows")?"":"lib";
 126         String libsuffix = os_name.contains("Windows")?".dll":
 127                                 os_name.contains("OS X")?".dylib":".so";
 128         boolean d64      = os_name.contains("Solaris");
 129         boolean hprof    = demo_name.equals("hprof");
 130         String java      = jre_home
 131                              + File.separator + "bin"
 132                              + File.separator + "java";
 133         /* Array of strings to be passed in for exec:
 134          *   1. java
 135          *   2. -Dtest.classes=.
 136          *   3. -d64                 (optional)
 137          *   4. -Xcheck:jni          (Just because it finds bugs)
 138          *   5. -Xverify:all         (Make sure verification is on full blast)
 139          *   6. -agent
 140          *       vm_options
 141          *   7+i. classname
 142          */
 143         int nvm_options = 0;
 144         if ( vm_options != null ) nvm_options = vm_options.length;
 145         String cmd[]     = new String[1 + (d64?1:0) + 7 + nvm_options];
 146         String cmdLine;
 147         int exitStatus;
 148         int i,j;
 149 
 150         i = 0;
 151         cmdLine = "";
 152         cmdLine += (cmd[i++] = java);
 153         cmdLine += " ";
 154         cmdLine += (cmd[i++] = "-cp");
 155         cmdLine += " ";
 156         cmdLine += (cmd[i++] = cdir);
 157         cmdLine += " ";
 158         cmdLine += (cmd[i++] = "-Dtest.classes=" + cdir);
 159         if ( d64 ) {
 160             cmdLine += " ";
 161             cmdLine += (cmd[i++] = "-d64");
 162         }
 163         cmdLine += " ";
 164         cmdLine += (cmd[i++] = "-Xcheck:jni");
 165         cmdLine += " ";
 166         cmdLine += (cmd[i++] = "-Xverify:all");
 167         if ( hprof ) {
 168             /* Load hprof with -agentlib since it's part of jre */
 169             cmdLine += " ";
 170             cmdLine += (cmd[i++] = "-agentlib:" + demo_name
 171                      + (demo_options.equals("")?"":("="+demo_options)));
 172         } else {
 173             String libname  = sdk_home
 174                          + File.separator + "demo"
 175                          + File.separator + "jvmti"
 176                          + File.separator + demo_name
 177                          + File.separator + "lib"
 178                          + File.separator + libprefix + demo_name + libsuffix;
 179             cmdLine += " ";
 180             cmdLine += (cmd[i++] = "-agentpath:" + libname
 181                      + (demo_options.equals("")?"":("="+demo_options)));
 182         }
 183         /* Add any special VM options */




 108     {
 109         runit(class_name, null);
 110     }
 111 
 112     /*
 113      * Execute a process with an -agentpath or -agentlib command option
 114      *    plus any set of other java options.
 115      */
 116     public void runit(String class_name, String vm_options[])
 117     {
 118         String jre_home  = System.getProperty("java.home");
 119         String sdk_home  = (jre_home.endsWith("jre") ?
 120                             (jre_home + File.separator + "..") :
 121                             jre_home );
 122         String cdir      = System.getProperty("test.classes", ".");
 123         String os_arch   = System.getProperty("os.arch");
 124         String os_name   = System.getProperty("os.name");
 125         String libprefix = os_name.contains("Windows")?"":"lib";
 126         String libsuffix = os_name.contains("Windows")?".dll":
 127                                 os_name.contains("OS X")?".dylib":".so";

 128         boolean hprof    = demo_name.equals("hprof");
 129         String java      = jre_home
 130                              + File.separator + "bin"
 131                              + File.separator + "java";
 132         /* Array of strings to be passed in for exec:
 133          *   1. java
 134          *   2. -Dtest.classes=.
 135          *   3. -Xcheck:jni          (Just because it finds bugs)
 136          *   4. -Xverify:all         (Make sure verification is on full blast)
 137          *   5. -agent

 138          *       vm_options
 139          *   6+i. classname
 140          */
 141         int nvm_options = 0;
 142         if ( vm_options != null ) nvm_options = vm_options.length;
 143         String cmd[]     = new String[1 + 7 + nvm_options];
 144         String cmdLine;
 145         int exitStatus;
 146         int i,j;
 147 
 148         i = 0;
 149         cmdLine = "";
 150         cmdLine += (cmd[i++] = java);
 151         cmdLine += " ";
 152         cmdLine += (cmd[i++] = "-cp");
 153         cmdLine += " ";
 154         cmdLine += (cmd[i++] = cdir);
 155         cmdLine += " ";
 156         cmdLine += (cmd[i++] = "-Dtest.classes=" + cdir);

 157         cmdLine += " ";



 158         cmdLine += (cmd[i++] = "-Xcheck:jni");
 159         cmdLine += " ";
 160         cmdLine += (cmd[i++] = "-Xverify:all");
 161         if ( hprof ) {
 162             /* Load hprof with -agentlib since it's part of jre */
 163             cmdLine += " ";
 164             cmdLine += (cmd[i++] = "-agentlib:" + demo_name
 165                      + (demo_options.equals("")?"":("="+demo_options)));
 166         } else {
 167             String libname  = sdk_home
 168                          + File.separator + "demo"
 169                          + File.separator + "jvmti"
 170                          + File.separator + demo_name
 171                          + File.separator + "lib"
 172                          + File.separator + libprefix + demo_name + libsuffix;
 173             cmdLine += " ";
 174             cmdLine += (cmd[i++] = "-agentpath:" + libname
 175                      + (demo_options.equals("")?"":("="+demo_options)));
 176         }
 177         /* Add any special VM options */