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

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 75,103 **** } MonitoredVm vm = null; String vmidString = "//" + lvmid + "?mode=r"; try { VmIdentifier id = new VmIdentifier(vmidString); vm = monitoredHost.getMonitoredVm(id, 0); } catch (URISyntaxException e) { // unexpected as vmidString is based on a validated hostid lastError = e; assert false; } catch (Exception e) { lastError = e; } finally { ! if (vm == null) { /* * we ignore most exceptions, as there are race * conditions where a JVM in 'jvms' may terminate * before we get a chance to list its information. * Other errors, such as access and I/O exceptions * should stop us from iterating over the complete set. */ ! output.append(" -- process information unavailable"); if (arguments.isDebug()) { if ((lastError != null) && (lastError.getMessage() != null)) { output.append("\n\t"); output.append(lastError.getMessage()); --- 75,146 ---- } MonitoredVm vm = null; String vmidString = "//" + lvmid + "?mode=r"; + String errorString = null; + try { + // Note: The VM associated with the current VM id may + // no longer be running so these queries may fail. We + // already added the VM id to the output stream above. + // If one of the queries fails, then we try to add a + // reasonable message to indicate that the requested + // info is not available. + + errorString = " -- process information unavailable"; VmIdentifier id = new VmIdentifier(vmidString); vm = monitoredHost.getMonitoredVm(id, 0); + + errorString = " -- main class information unavailable"; + output.append(" " + MonitoredVmUtil.mainClass(vm, + arguments.showLongPaths())); + + if (arguments.showMainArgs()) { + errorString = " -- main args information unavailable"; + String mainArgs = MonitoredVmUtil.mainArgs(vm); + if (mainArgs != null && mainArgs.length() > 0) { + output.append(" " + mainArgs); + } + } + if (arguments.showVmArgs()) { + errorString = " -- jvm args information unavailable"; + String jvmArgs = MonitoredVmUtil.jvmArgs(vm); + if (jvmArgs != null && jvmArgs.length() > 0) { + output.append(" " + jvmArgs); + } + } + if (arguments.showVmFlags()) { + errorString = " -- jvm flags information unavailable"; + String jvmFlags = MonitoredVmUtil.jvmFlags(vm); + if (jvmFlags != null && jvmFlags.length() > 0) { + output.append(" " + jvmFlags); + } + } + + errorString = " -- detach failed"; + monitoredHost.detach(vm); + + System.out.println(output); + + errorString = null; } catch (URISyntaxException e) { // unexpected as vmidString is based on a validated hostid lastError = e; assert false; } catch (Exception e) { lastError = e; } finally { ! if (errorString != null) { /* * we ignore most exceptions, as there are race * conditions where a JVM in 'jvms' may terminate * before we get a chance to list its information. * Other errors, such as access and I/O exceptions * should stop us from iterating over the complete set. */ ! output.append(errorString); if (arguments.isDebug()) { if ((lastError != null) && (lastError.getMessage() != null)) { output.append("\n\t"); output.append(lastError.getMessage());
*** 108,145 **** lastError.printStackTrace(); } continue; } } - - output.append(" "); - output.append(MonitoredVmUtil.mainClass(vm, - arguments.showLongPaths())); - - if (arguments.showMainArgs()) { - String mainArgs = MonitoredVmUtil.mainArgs(vm); - if (mainArgs != null && mainArgs.length() > 0) { - output.append(" ").append(mainArgs); } - } - if (arguments.showVmArgs()) { - String jvmArgs = MonitoredVmUtil.jvmArgs(vm); - if (jvmArgs != null && jvmArgs.length() > 0) { - output.append(" ").append(jvmArgs); - } - } - if (arguments.showVmFlags()) { - String jvmFlags = MonitoredVmUtil.jvmFlags(vm); - if (jvmFlags != null && jvmFlags.length() > 0) { - output.append(" ").append(jvmFlags); - } - } - - System.out.println(output); - - monitoredHost.detach(vm); - } } catch (MonitorException e) { if (e.getMessage() != null) { System.err.println(e.getMessage()); } else { Throwable cause = e.getCause(); --- 151,161 ----