Java Code Examples for jdk.jfr.consumer.RecordedFrame#isJavaFrame()

The following examples show how to use jdk.jfr.consumer.RecordedFrame#isJavaFrame() . 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: TestGetStackTrace.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void assertFrame(RecordedFrame frame) {
    int bci = frame.getBytecodeIndex();
    int line = frame.getLineNumber();
    boolean javaFrame = frame.isJavaFrame();
    RecordedMethod method = frame.getMethod();
    String type = frame.getType();
    System.out.println("*** Frame Info ***");
    System.out.println("bci=" + bci);
    System.out.println("line=" + line);
    System.out.println("type=" + type);
    System.out.println("method=" + method);
    System.out.println("***");
    Asserts.assertTrue(javaFrame, "Only Java frame are currently supported");
    Asserts.assertGreaterThanOrEqual(bci, -1);
    Asserts.assertNotNull(method, "Method should not be null");
}
 
Example 2
Source File: PrettyWriter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private void printStackTrace(RecordedStackTrace stackTrace) {
    println("[");
    List<RecordedFrame> frames = stackTrace.getFrames();
    indent();
    int i = 0;
    while (i < frames.size() && i < getStackDepth()) {
        RecordedFrame frame = frames.get(i);
        if (frame.isJavaFrame()) {
            printIndent();
            printValue(frame, null, "");
            println();
            i++;
        }
    }
    if (stackTrace.isTruncated() || i == getStackDepth()) {
        printIndent();
        println("...");
    }
    retract();
    printIndent();
    println("]");
}
 
Example 3
Source File: TestGetStackTrace.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void assertFrame(RecordedFrame frame) {
    int bci = frame.getBytecodeIndex();
    int line = frame.getLineNumber();
    boolean javaFrame = frame.isJavaFrame();
    RecordedMethod method = frame.getMethod();
    String type = frame.getType();
    System.out.println("*** Frame Info ***");
    System.out.println("bci=" + bci);
    System.out.println("line=" + line);
    System.out.println("type=" + type);
    System.out.println("method=" + method);
    System.out.println("***");
    Asserts.assertTrue(javaFrame, "Only Java frame are currently supported");
    Asserts.assertGreaterThanOrEqual(bci, -1);
    Asserts.assertNotNull(method, "Method should not be null");
}
 
Example 4
Source File: PrettyWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private void printStackTrace(RecordedStackTrace stackTrace) {
    println("[");
    List<RecordedFrame> frames = stackTrace.getFrames();
    indent();
    int i = 0;
    while (i < frames.size() && i < getStackDepth()) {
        RecordedFrame frame = frames.get(i);
        if (frame.isJavaFrame()) {
            printIndent();
            printValue(frame, null, "");
            println();
            i++;
        }
    }
    if (stackTrace.isTruncated() || i == getStackDepth()) {
        printIndent();
        println("...");
    }
    retract();
    printIndent();
    println("]");
}
 
Example 5
Source File: TestGetStackTrace.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void assertFrame(RecordedFrame frame) {
    int bci = frame.getBytecodeIndex();
    int line = frame.getLineNumber();
    boolean javaFrame = frame.isJavaFrame();
    RecordedMethod method = frame.getMethod();
    String type = frame.getType();
    System.out.println("*** Frame Info ***");
    System.out.println("bci=" + bci);
    System.out.println("line=" + line);
    System.out.println("type=" + type);
    System.out.println("method=" + method);
    System.out.println("***");
    Asserts.assertTrue(javaFrame, "Only Java frame are currently supported");
    Asserts.assertGreaterThanOrEqual(bci, -1);
    Asserts.assertNotNull(method, "Method should not be null");
}
 
Example 6
Source File: PrettyWriter.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private void printValue(Object value, ValueDescriptor field, String postFix) {
    if (value == null) {
        println("N/A" + postFix);
        return;
    }
    if (value instanceof RecordedObject) {
        if (value instanceof RecordedThread) {
            printThread((RecordedThread) value, postFix);
            return;
        }
        if (value instanceof RecordedClass) {
            printClass((RecordedClass) value, postFix);
            return;
        }
        if (value instanceof RecordedClassLoader) {
            printClassLoader((RecordedClassLoader) value, postFix);
            return;
        }
        if (value instanceof RecordedFrame) {
            RecordedFrame frame = (RecordedFrame) value;
            if (frame.isJavaFrame()) {
                printJavaFrame((RecordedFrame) value, postFix);
                return;
            }
        }
        if (value instanceof RecordedMethod) {
            println(formatMethod((RecordedMethod) value));
            return;
        }
        if (field.getTypeName().equals(TYPE_OLD_OBJECT)) {
            printOldObject((RecordedObject) value);
            return;
        }
         print((RecordedObject) value, postFix);
        return;
    }
    if (value.getClass().isArray()) {
        printArray((Object[]) value);
        return;
    }

    if (value instanceof Double) {
        Double d = (Double) value;
        if (Double.isNaN(d) || d == Double.NEGATIVE_INFINITY) {
            println("N/A");
            return;
        }
    }
    if (value instanceof Float) {
        Float f = (Float) value;
        if (Float.isNaN(f) || f == Float.NEGATIVE_INFINITY) {
            println("N/A");
            return;
        }
    }
    if (value instanceof Long) {
        Long l = (Long) value;
        if (l == Long.MIN_VALUE) {
            println("N/A");
            return;
        }
    }
    if (value instanceof Integer) {
        Integer i = (Integer) value;
        if (i == Integer.MIN_VALUE) {
            println("N/A");
            return;
        }
    }

    if (field.getContentType() != null) {
        if (printFormatted(field, value)) {
            return;
        }
    }

    String text = String.valueOf(value);
    if (value instanceof String) {
        text = "\"" + text + "\"";
    }
    println(text);
}
 
Example 7
Source File: PrettyWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private void printValue(Object value, ValueDescriptor field, String postFix) {
    if (value == null) {
        println("N/A" + postFix);
        return;
    }
    if (value instanceof RecordedObject) {
        if (value instanceof RecordedThread) {
            printThread((RecordedThread) value, postFix);
            return;
        }
        if (value instanceof RecordedClass) {
            printClass((RecordedClass) value, postFix);
            return;
        }
        if (value instanceof RecordedClassLoader) {
            printClassLoader((RecordedClassLoader) value, postFix);
            return;
        }
        if (value instanceof RecordedFrame) {
            RecordedFrame frame = (RecordedFrame) value;
            if (frame.isJavaFrame()) {
                printJavaFrame((RecordedFrame) value, postFix);
                return;
            }
        }
        if (value instanceof RecordedMethod) {
            println(formatMethod((RecordedMethod) value));
            return;
        }
        if (field.getTypeName().equals(TYPE_OLD_OBJECT)) {
            printOldObject((RecordedObject) value);
            return;
        }
         print((RecordedObject) value, postFix);
        return;
    }
    if (value.getClass().isArray()) {
        printArray((Object[]) value);
        return;
    }

    if (value instanceof Double) {
        Double d = (Double) value;
        if (Double.isNaN(d) || d == Double.NEGATIVE_INFINITY) {
            println("N/A");
            return;
        }
    }
    if (value instanceof Float) {
        Float f = (Float) value;
        if (Float.isNaN(f) || f == Float.NEGATIVE_INFINITY) {
            println("N/A");
            return;
        }
    }
    if (value instanceof Long) {
        Long l = (Long) value;
        if (l == Long.MIN_VALUE) {
            println("N/A");
            return;
        }
    }
    if (value instanceof Integer) {
        Integer i = (Integer) value;
        if (i == Integer.MIN_VALUE) {
            println("N/A");
            return;
        }
    }

    if (field.getContentType() != null) {
        if (printFormatted(field, value)) {
            return;
        }
    }

    String text = String.valueOf(value);
    if (value instanceof String) {
        text = "\"" + text + "\"";
    }
    println(text);
}