< prev index next >

src/jdk.jcmd/share/classes/sun/tools/jps/Jps.java

Print this page
rev 10793 : 8055723: Replace concat String to append in StringBuilder parameters


  75                 }
  76 
  77                 MonitoredVm vm = null;
  78                 String vmidString = "//" + lvmid + "?mode=r";
  79 
  80                 String errorString = null;
  81 
  82                 try {
  83                     // Note: The VM associated with the current VM id may
  84                     // no longer be running so these queries may fail. We
  85                     // already added the VM id to the output stream above.
  86                     // If one of the queries fails, then we try to add a
  87                     // reasonable message to indicate that the requested
  88                     // info is not available.
  89 
  90                     errorString = " -- process information unavailable";
  91                     VmIdentifier id = new VmIdentifier(vmidString);
  92                     vm = monitoredHost.getMonitoredVm(id, 0);
  93 
  94                     errorString = " -- main class information unavailable";
  95                     output.append(" " + MonitoredVmUtil.mainClass(vm,
  96                             arguments.showLongPaths()));
  97 
  98                     if (arguments.showMainArgs()) {
  99                         errorString = " -- main args information unavailable";
 100                         String mainArgs = MonitoredVmUtil.mainArgs(vm);
 101                         if (mainArgs != null && mainArgs.length() > 0) {
 102                             output.append(" " + mainArgs);
 103                         }
 104                     }
 105                     if (arguments.showVmArgs()) {
 106                         errorString = " -- jvm args information unavailable";
 107                         String jvmArgs = MonitoredVmUtil.jvmArgs(vm);
 108                         if (jvmArgs != null && jvmArgs.length() > 0) {
 109                           output.append(" " + jvmArgs);
 110                         }
 111                     }
 112                     if (arguments.showVmFlags()) {
 113                         errorString = " -- jvm flags information unavailable";
 114                         String jvmFlags = MonitoredVmUtil.jvmFlags(vm);
 115                         if (jvmFlags != null && jvmFlags.length() > 0) {
 116                             output.append(" " + jvmFlags);
 117                         }
 118                     }
 119 
 120                     errorString = " -- detach failed";
 121                     monitoredHost.detach(vm);
 122 
 123                     System.out.println(output);
 124 
 125                     errorString = null;
 126                 } catch (URISyntaxException e) {
 127                     // unexpected as vmidString is based on a validated hostid
 128                     lastError = e;
 129                     assert false;
 130                 } catch (Exception e) {
 131                     lastError = e;
 132                 } finally {
 133                     if (errorString != null) {
 134                         /*
 135                          * we ignore most exceptions, as there are race
 136                          * conditions where a JVM in 'jvms' may terminate




  75                 }
  76 
  77                 MonitoredVm vm = null;
  78                 String vmidString = "//" + lvmid + "?mode=r";
  79 
  80                 String errorString = null;
  81 
  82                 try {
  83                     // Note: The VM associated with the current VM id may
  84                     // no longer be running so these queries may fail. We
  85                     // already added the VM id to the output stream above.
  86                     // If one of the queries fails, then we try to add a
  87                     // reasonable message to indicate that the requested
  88                     // info is not available.
  89 
  90                     errorString = " -- process information unavailable";
  91                     VmIdentifier id = new VmIdentifier(vmidString);
  92                     vm = monitoredHost.getMonitoredVm(id, 0);
  93 
  94                     errorString = " -- main class information unavailable";
  95                     output.append(' ').append(MonitoredVmUtil.mainClass(vm,
  96                             arguments.showLongPaths()));
  97 
  98                     if (arguments.showMainArgs()) {
  99                         errorString = " -- main args information unavailable";
 100                         String mainArgs = MonitoredVmUtil.mainArgs(vm);
 101                         if (mainArgs != null && mainArgs.length() > 0) {
 102                             output.append(' ').append(mainArgs);
 103                         }
 104                     }
 105                     if (arguments.showVmArgs()) {
 106                         errorString = " -- jvm args information unavailable";
 107                         String jvmArgs = MonitoredVmUtil.jvmArgs(vm);
 108                         if (jvmArgs != null && jvmArgs.length() > 0) {
 109                           output.append(' ').append(jvmArgs);
 110                         }
 111                     }
 112                     if (arguments.showVmFlags()) {
 113                         errorString = " -- jvm flags information unavailable";
 114                         String jvmFlags = MonitoredVmUtil.jvmFlags(vm);
 115                         if (jvmFlags != null && jvmFlags.length() > 0) {
 116                             output.append(' ').append(jvmFlags);
 117                         }
 118                     }
 119 
 120                     errorString = " -- detach failed";
 121                     monitoredHost.detach(vm);
 122 
 123                     System.out.println(output);
 124 
 125                     errorString = null;
 126                 } catch (URISyntaxException e) {
 127                     // unexpected as vmidString is based on a validated hostid
 128                     lastError = e;
 129                     assert false;
 130                 } catch (Exception e) {
 131                     lastError = e;
 132                 } finally {
 133                     if (errorString != null) {
 134                         /*
 135                          * we ignore most exceptions, as there are race
 136                          * conditions where a JVM in 'jvms' may terminate


< prev index next >