Java Method Call invokeMXMethod(String methodName)

Here you can find the source of invokeMXMethod(String methodName)

Description

invoke MX Method

License

Apache License

Declaration

public static Object invokeMXMethod(String methodName) throws NoSuchMethodException, SecurityException,
            IllegalAccessException, IllegalArgumentException, InvocationTargetException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Main {
    public static Object invokeMXMethod(String methodName) throws NoSuchMethodException, SecurityException,
            IllegalAccessException, IllegalArgumentException, InvocationTargetException {
        OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
        Method m = operatingSystemMXBean.getClass().getDeclaredMethod(methodName);
        m.setAccessible(true);//  w w w .  jav a 2 s . c  om
        return m.invoke(operatingSystemMXBean);
    }
}

Related

  1. invokeGetClasspathMethodIfItExists(ClassLoader cl)
  2. invokeGetMethodWithSameName(Object object, Method method)
  3. invokeHeritedMethod(Object target, String method, Class klass)
  4. invokeInstanceMethod(Object target, String methodName, Class type, Object arg)
  5. invokeIteratorCallable(String callableClassName, ClassLoader cl)
  6. invokeNoArgs(Object instance, Method method, Class returnType)
  7. invokeNoArgsMethod(Object object, String methodName)
  8. invokeNonAccessibleMethod(Class clazz, String methodName, Object instance, Object... params)
  9. invokeNonArgMethod(Object object, String methodName)