Example usage for java.lang.management PlatformManagedObject getClass

List of usage examples for java.lang.management PlatformManagedObject getClass

Introduction

In this page you can find the example usage for java.lang.management PlatformManagedObject getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.kuali.test.runner.execution.TestExecutionContext.java

private String getValueFromMXBeanObject(String name, PlatformManagedObject mxbean) {
    String retval = null;//from  ww  w.j a  va2  s  .  c o  m

    try {
        Method m = mxbean.getClass().getMethod("get" + name, new Class[0]);

        if (m != null) {
            Object o = m.invoke(mxbean);

            if (o != null) {
                if (o instanceof MemoryUsage) {
                    MemoryUsage mu = (MemoryUsage) o;
                    retval = "" + mu.getUsed();
                } else {
                    retval = o.toString();
                }
            }
        }
    }

    catch (Exception ex) {
    }
    ;

    return retval;
}