Java Code Examples for jdk.jfr.consumer.RecordedClass#getName()

The following examples show how to use jdk.jfr.consumer.RecordedClass#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrettyWriter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
void printObject(RecordedObject object, long arraySize) {
    RecordedClass clazz = object.getClass("type");
    if (clazz != null) {
        String className = clazz.getName();
        if (className!= null && className.startsWith("[")) {
            className = decodeDescriptors(className, arraySize > 0 ? Long.toString(arraySize) : "").get(0);
        }
        print(className);
        String description = object.getString("description");
        if (description != null) {
            print(" ");
            print(description);
        }
    }
    println();
}
 
Example 2
Source File: PrettyWriter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private void printClass(RecordedClass clazz, String postFix) {
    RecordedClassLoader classLoader = clazz.getClassLoader();
    String classLoaderName = "null";
    if (classLoader != null) {
        if (classLoader.getName() != null) {
            classLoaderName = classLoader.getName();
        } else {
            classLoaderName = classLoader.getType().getName();
        }
    }
    String className = clazz.getName();
    if (className.startsWith("[")) {
        className = decodeDescriptors(className, "").get(0);
    }
    println(className + " (classLoader = " + classLoaderName + ")" + postFix);
}
 
Example 3
Source File: PrettyWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
void printObject(RecordedObject object, long arraySize) {
    RecordedClass clazz = object.getClass("type");
    if (clazz != null) {
        String className = clazz.getName();
        if (className!= null && className.startsWith("[")) {
            className = decodeDescriptors(className, arraySize > 0 ? Long.toString(arraySize) : "").get(0);
        }
        print(className);
        String description = object.getString("description");
        if (description != null) {
            print(" ");
            print(description);
        }
    }
    println();
}
 
Example 4
Source File: PrettyWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private void printClass(RecordedClass clazz, String postFix) {
    RecordedClassLoader classLoader = clazz.getClassLoader();
    String classLoaderName = "null";
    if (classLoader != null) {
        if (classLoader.getName() != null) {
            classLoaderName = classLoader.getName();
        } else {
            classLoaderName = classLoader.getType().getName();
        }
    }
    String className = clazz.getName();
    if (className.startsWith("[")) {
        className = decodeDescriptors(className, "").get(0);
    }
    println(className + " (classLoader = " + classLoaderName + ")" + postFix);
}
 
Example 5
Source File: TestArrayInformation.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void verifyObjectArray(List<RecordedEvent> events) throws Exception {
    for (RecordedEvent e : events) {
        RecordedObject object = e.getValue("object");
        RecordedClass objectType = object.getValue("type");
        RecordedObject referrer = object.getValue("referrer");
        System.out.println(objectType.getName());
        if (objectType.getName().equals(ArrayLeak[].class.getName())) {
            for (int i = 0; i < CHAIN_DEPTH; i++) {
                object = referrer.getValue("object");
                if (object == null) {
                    throw new Exception("Expected referrer object");
                }
                objectType = object.getValue("type");
                if (!objectType.getName().equals(Object[].class.getName())) {
                    throw new Exception("Expect array class to be named " + Object[].class + " but found " + objectType.getName());
                }
                RecordedObject field = referrer.getValue("field");
                if (field != null) {
                    throw new Exception("Didn't expect to find field");
                }
                RecordedObject array = referrer.getValue("array");
                if (array == null) {
                    throw new Exception("Expected array object, but got null");
                }
                int index = referrer.getValue("array.index");
                if (index != ARRAY_INDEX) {
                    throw new Exception("Expected array index: " + ARRAY_INDEX + ", but got " + index);
                }
                int size = referrer.getValue("array.size");
                if (size != ARRAY_SIZE) {
                    throw new Exception("Expected array size: " + ARRAY_SIZE + ", but got " + size);
                }
                referrer = object.getValue("referrer");
            }
            return;
        }
    }
    throw new Exception("Could not find event with " + ArrayLeak[].class + " as (leak) object");
}
 
Example 6
Source File: TestArrayInformation.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void verifyObjectArray(List<RecordedEvent> events) throws Exception {
    for (RecordedEvent e : events) {
        RecordedObject object = e.getValue("object");
        RecordedClass objectType = object.getValue("type");
        RecordedObject referrer = object.getValue("referrer");
        System.out.println(objectType.getName());
        if (objectType.getName().equals(ArrayLeak[].class.getName())) {
            for (int i = 0; i < CHAIN_DEPTH; i++) {
                object = referrer.getValue("object");
                if (object == null) {
                    throw new Exception("Expected referrer object");
                }
                objectType = object.getValue("type");
                if (!objectType.getName().equals(Object[].class.getName())) {
                    throw new Exception("Expect array class to be named " + Object[].class + " but found " + objectType.getName());
                }
                RecordedObject field = referrer.getValue("field");
                if (field != null) {
                    throw new Exception("Didn't expect to find field");
                }
                RecordedObject array = referrer.getValue("array");
                if (array == null) {
                    throw new Exception("Expected array object, but got null");
                }
                int index = referrer.getValue("array.index");
                if (index != ARRAY_INDEX) {
                    throw new Exception("Expected array index: " + ARRAY_INDEX + ", but got " + index);
                }
                int size = referrer.getValue("array.size");
                if (size != ARRAY_SIZE) {
                    throw new Exception("Expected array size: " + ARRAY_SIZE + ", but got " + size);
                }
                referrer = object.getValue("referrer");
            }
            return;
        }
    }
    throw new Exception("Could not find event with " + ArrayLeak[].class + " as (leak) object");
}
 
Example 7
Source File: TestArrayInformation.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void verifyObjectArray(List<RecordedEvent> events) throws Exception {
    for (RecordedEvent e : events) {
        RecordedObject object = e.getValue("object");
        RecordedClass objectType = object.getValue("type");
        RecordedObject referrer = object.getValue("referrer");
        System.out.println(objectType.getName());
        if (objectType.getName().equals(ArrayLeak[].class.getName())) {
            for (int i = 0; i < CHAIN_DEPTH; i++) {
                object = referrer.getValue("object");
                if (object == null) {
                    throw new Exception("Expected referrer object");
                }
                objectType = object.getValue("type");
                if (!objectType.getName().equals(Object[].class.getName())) {
                    throw new Exception("Expect array class to be named " + Object[].class + " but found " + objectType.getName());
                }
                RecordedObject field = referrer.getValue("field");
                if (field != null) {
                    throw new Exception("Didn't expect to find field");
                }
                RecordedObject array = referrer.getValue("array");
                if (array == null) {
                    throw new Exception("Expected array object, but got null");
                }
                int index = referrer.getValue("array.index");
                if (index != ARRAY_INDEX) {
                    throw new Exception("Expected array index: " + ARRAY_INDEX + ", but got " + index);
                }
                int size = referrer.getValue("array.size");
                if (size != ARRAY_SIZE) {
                    throw new Exception("Expected array size: " + ARRAY_SIZE + ", but got " + size);
                }
                referrer = object.getValue("referrer");
            }
            return;
        }
    }
    throw new Exception("Could not find event with " + ArrayLeak[].class + " as (leak) object");
}