当前位置: 首页>>代码示例>>Java>>正文


Java VMManagement类代码示例

本文整理汇总了Java中sun.management.VMManagement的典型用法代码示例。如果您正苦于以下问题:Java VMManagement类的具体用法?Java VMManagement怎么用?Java VMManagement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


VMManagement类属于sun.management包,在下文中一共展示了VMManagement类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getProcessId

import sun.management.VMManagement; //导入依赖的package包/类
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;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:JdpController.java

示例2: getProcessId

import sun.management.VMManagement; //导入依赖的package包/类
public int getProcessId()
{
    try
    {
        RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
        Field jvmField = runtimeMXBean.getClass().getDeclaredField("jvm");
        jvmField.setAccessible(true);
        VMManagement vmManagement = (VMManagement) jvmField.get(runtimeMXBean);
        Method getProcessIdMethod = vmManagement.getClass().getDeclaredMethod("getProcessId");
        getProcessIdMethod.setAccessible(true);
        return (Integer) getProcessIdMethod.invoke(vmManagement);
    }
    catch (Exception exception)
    {
        logger.log(Level.INFO, exception.getMessage(), exception);
    }

    return -1;
}
 
开发者ID:geekflow,项目名称:light,代码行数:20,代码来源:JavaProcess.java

示例3: getDiagnosticCommandMBean

import sun.management.VMManagement; //导入依赖的package包/类
static synchronized DiagnosticCommandMBean getDiagnosticCommandMBean() {
    VMManagement jvm = ManagementFactoryHelper.getVMManagement();

    // Remote Diagnostic Commands may not be supported
    if (diagCommandMBean == null && jvm.isRemoteDiagnosticCommandsSupported()) {
        diagCommandMBean = new DiagnosticCommandImpl(jvm);
    }
    return diagCommandMBean;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:DiagnosticCommandImpl.java

示例4: getPid

import sun.management.VMManagement; //导入依赖的package包/类
/**
 * Returns the pid of the current process.
 * This fails on systems without process identifiers.
 *
 * @return the processes pid
 * @throws NoSuchFieldException if the JVM does not support the VMManagement class
 * @throws IllegalAccessException if the JVM does not support the VMManagement class
 * @throws NoSuchMethodException if the JVM does not support pids.
 * @throws InvocationTargetException if the JVM does not support pids.
 */
public static int getPid()
    throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException,
    InvocationTargetException {
  RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
  Field jvm = runtime.getClass().getDeclaredField("jvm");
  jvm.setAccessible(true);

  VMManagement mgmt = (VMManagement) jvm.get(runtime);
  Method getProcessId = mgmt.getClass().getDeclaredMethod("getProcessId");
  getProcessId.setAccessible(true);

  return (Integer) getProcessId.invoke(mgmt);
}
 
开发者ID:bramp,项目名称:unsafe,代码行数:24,代码来源:MemoryUtils.java

示例5: getOperatingSystemMXBean

import sun.management.VMManagement; //导入依赖的package包/类
public static synchronized OperatingSystemMXBean
    getOperatingSystemMXBean(VMManagement jvm) {

    if (osMBean == null) {
        osMBean = new OperatingSystem(jvm);
    }
    return (OperatingSystemMXBean) osMBean;
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:9,代码来源:OSMBeanFactory.java

示例6: getOperatingSystemMXBean

import sun.management.VMManagement; //导入依赖的package包/类
public static synchronized OperatingSystemMXBean
    getOperatingSystemMXBean(VMManagement jvm) {

    if (osMBean == null) {
        osMBean = new UnixOperatingSystem(jvm);
    }
    return (OperatingSystemMXBean) osMBean;
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:9,代码来源:OSMBeanFactory.java

示例7: getPIDForOracleJVM

import sun.management.VMManagement; //导入依赖的package包/类
protected static int getPIDForOracleJVM() throws Exception {
	RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
	Field jvm = runtime.getClass().getDeclaredField("jvm");
	jvm.setAccessible(true);
	VMManagement mgmt = (VMManagement) jvm.get(runtime);
	Method getProcessId = mgmt.getClass().getDeclaredMethod("getProcessId");
	getProcessId.setAccessible(true);

	return (Integer) getProcessId.invoke(mgmt);
}
 
开发者ID:bitgamma,项目名称:updatefx,代码行数:11,代码来源:PIDUtil.java

示例8: jvmPid

import sun.management.VMManagement; //导入依赖的package包/类
public static final int jvmPid() {
    try {
        RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
        Field jvm = runtime.getClass().getDeclaredField("jvm");
        jvm.setAccessible(true);
        VMManagement mgmt = (VMManagement) jvm.get(runtime);
        Method pidMethod = mgmt.getClass().getDeclaredMethod("getProcessId");
        pidMethod.setAccessible(true);
        int pid = (Integer) pidMethod.invoke(mgmt);
        return pid;
    } catch (Exception e) {
        return -1;
    }
}
 
开发者ID:brucexx,项目名称:heisenberg,代码行数:15,代码来源:HeisenbergStartup.java

示例9: getProcessId

import sun.management.VMManagement; //导入依赖的package包/类
/**
 * Get the process id of the current running Java process
 *
 * @return Process id
 */
public static int getProcessId() throws Exception {

  // 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);

  int pid = (Integer) pid_method.invoke(mgmt);

  return pid;
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:23,代码来源:ProcessTools.java

示例10: getProcessId

import sun.management.VMManagement; //导入依赖的package包/类
/**
 * Get the process id of the current running Java process
 *
 * @return Process id
 */
public static int getProcessId() throws Exception {

    // 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);

    int pid = (Integer) pid_method.invoke(mgmt);

    return pid;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:ProcessTools.java

示例11: DiagnosticCommandImpl

import sun.management.VMManagement; //导入依赖的package包/类
DiagnosticCommandImpl(VMManagement jvm) {
    this.jvm = jvm;
    isSupported = jvm.isRemoteDiagnosticCommandsSupported();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:DiagnosticCommandImpl.java

示例12: HotSpotThreadImpl

import sun.management.VMManagement; //导入依赖的package包/类
public HotSpotThreadImpl(VMManagement vm) {
    super(ManagementFactoryHelper.getVMManagement());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:HotSpotThreadImpl.java

示例13: OperatingSystemImpl

import sun.management.VMManagement; //导入依赖的package包/类
OperatingSystemImpl(VMManagement vm) {
    super(vm);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:OperatingSystemImpl.java

示例14: getProcessId

import sun.management.VMManagement; //导入依赖的package包/类
public static int getProcessId() throws Exception {

        // 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);

        int pid = (Integer) pid_method.invoke(mgmt);

        return pid;
    }
 
开发者ID:campolake,项目名称:openjdk9,代码行数:18,代码来源:JMapHProfLargeHeapProc.java


注:本文中的sun.management.VMManagement类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。