use of java.lang.management.RuntimeMXBean in project jdk8u_jdk by JetBrains.
the class JdpController method getProcessId.
// Get the process id of the current running Java process
private static Integer getProcessId() {
try {
// Get the current process id using a reflection hack
RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
Field jvm = runtime.getClass().getDeclaredField("jvm");
jvm.setAccessible(true);
VMManagement mgmt = (sun.management.VMManagement) jvm.get(runtime);
Method pid_method = mgmt.getClass().getDeclaredMethod("getProcessId");
pid_method.setAccessible(true);
Integer pid = (Integer) pid_method.invoke(mgmt);
return pid;
} catch (Exception ex) {
return null;
}
}
use of java.lang.management.RuntimeMXBean in project flink by apache.
the class EnvironmentInformation method getJvmStartupOptionsArray.
/**
* Gets the system parameters and environment parameters that were passed to the JVM on startup.
*
* @return The options passed to the JVM on startup.
*/
public static String[] getJvmStartupOptionsArray() {
try {
RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();
List<String> options = bean.getInputArguments();
return options.toArray(new String[options.size()]);
} catch (Throwable t) {
return new String[0];
}
}
use of java.lang.management.RuntimeMXBean in project tdi-studio-se by Talend.
the class MBeanServer method getJvmArguments.
/**
* Gets the JVM arguments.
*
* @return The JVM arguments
*/
public String getJvmArguments() {
if (!checkReachability()) {
//$NON-NLS-1$
return "";
}
List<String> arguments;
try {
RuntimeMXBean runtimeMXBean = (RuntimeMXBean) getMXBean(RuntimeMXBean.class, ManagementFactory.RUNTIME_MXBEAN_NAME);
arguments = runtimeMXBean.getInputArguments();
} catch (IOException e) {
//$NON-NLS-1$
Activator.log(IStatus.ERROR, NLS.bind(Messages.getAttributeFailedMsg, "InputArguments"), e);
//$NON-NLS-1$
return "";
}
StringBuffer buffer = new StringBuffer();
for (String argument : arguments) {
if (buffer.length() > 0) {
//$NON-NLS-1$
buffer.append(" ");
}
buffer.append(argument);
}
return buffer.toString();
}
use of java.lang.management.RuntimeMXBean in project tdi-studio-se by Talend.
the class RuntimeModel method getJvmArguments.
/**
* Gets the JVM arguments.
*
* @return The JVM arguments
*/
private static String getJvmArguments() {
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
List<String> arguments = runtimeMXBean.getInputArguments();
StringBuffer buffer = new StringBuffer();
for (String argument : arguments) {
if (buffer.length() > 0) {
buffer.append(" ");
}
buffer.append(argument);
}
return buffer.toString();
}
use of java.lang.management.RuntimeMXBean in project tdi-studio-se by Talend.
the class HeapHistogramPage method isSupported.
/**
* Gets the state indicating if heap histogram is supported.
* <p>
* WORKAROUND: Heap histogram is disabled on 64bit OS when monitoring eclipse itself, due to the issue that the
* method heapHisto() of the class HotSpotVirtualMachine causes continuously increasing the committed heap memory.
*
* @return <tt>true</tt> if heap histogram is supported
*/
boolean isSupported() {
IActiveJvm jvm = section.getJvm();
if (jvm == null) {
return false;
}
OperatingSystemMXBean osMBean = ManagementFactory.getOperatingSystemMXBean();
RuntimeMXBean runtimeMBean = ManagementFactory.getRuntimeMXBean();
if (osMBean.getArch().contains(ARCH_64BIT) && runtimeMBean.getName().contains(String.valueOf(jvm.getPid()))) {
return false;
}
return true;
}
Aggregations