< prev index next >

src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java

Print this page
rev 52026 : 8205654: serviceability/dcmd/framework/HelpTest.java timed out
8218705: Test sun/tools/jcmd/TestJcmdDefaults.java fails on Linux
Reviewed-by: sspitsyn, dholmes

*** 1,7 **** /* ! * Copyright (c) 2016, 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) 2016, 2019, 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
*** 76,104 **** } return excludeClass.getName(); } private static boolean check(VirtualMachineDescriptor vmd, String excludeClass, String partialMatch) { String mainClass = null; ! try { ! VmIdentifier vmId = new VmIdentifier(vmd.id()); ! MonitoredHost monitoredHost = MonitoredHost.getMonitoredHost(vmId); ! MonitoredVm monitoredVm = monitoredHost.getMonitoredVm(vmId, -1); ! mainClass = MonitoredVmUtil.mainClass(monitoredVm, true); ! monitoredHost.detach(monitoredVm); ! } catch (NullPointerException npe) { ! // There is a potential race, where a running java app is being ! // queried, unfortunately the java app has shutdown after this ! // method is started but before getMonitoredVM is called. ! // If this is the case, then the /tmp/hsperfdata_xxx/pid file ! // will have disappeared and we will get a NullPointerException. ! // Handle this gracefully.... ! return false; ! } catch (MonitorException | URISyntaxException e) { ! return false; } if (excludeClass != null && mainClass.equals(excludeClass)) { return false; } if (partialMatch != null && mainClass.indexOf(partialMatch) == -1) { --- 76,116 ---- } return excludeClass.getName(); } private static boolean check(VirtualMachineDescriptor vmd, String excludeClass, String partialMatch) { + String mainClass = null; ! ! // Get the main class name using platform specific helper ! ProcessHelper helper = ProcessHelper.platformProcessHelper(); ! if (helper != null) { ! mainClass = helper.getMainClass(vmd.id()); ! } ! ! // If the main class name is still unset then retrieve it with the attach mechanism ! if (mainClass == null) { ! try { ! VmIdentifier vmId = new VmIdentifier(vmd.id()); ! MonitoredHost monitoredHost = MonitoredHost.getMonitoredHost(vmId); ! MonitoredVm monitoredVm = monitoredHost.getMonitoredVm(vmId, -1); ! mainClass = MonitoredVmUtil.mainClass(monitoredVm, true); ! monitoredHost.detach(monitoredVm); ! } catch (NullPointerException npe) { ! // There is a potential race, where a running java app is being ! // queried, unfortunately the java app has shutdown after this ! // method is started but before getMonitoredVM is called. ! // If this is the case, then the /tmp/hsperfdata_xxx/pid file ! // will have disappeared and we will get a NullPointerException. ! // Handle this gracefully.... ! return false; ! } catch (MonitorException | URISyntaxException e) { ! return false; ! } } + if (excludeClass != null && mainClass.equals(excludeClass)) { return false; } if (partialMatch != null && mainClass.indexOf(partialMatch) == -1) {
< prev index next >