The API for Oracle JDK14, and JDK15 is published at https://docs.oracle.com/en/java/javase/14/jfapi/parsing-recording-file.html but I couldn't find similar documentation for Oracle JDK8.
I was wondering if someone was able to print out the list of events for a JFR file collected with JDK8, just like in the example shown by the docs for JDK14, and JDK15. In that case, what is the role of <jdk1.8>\jre\lib\jfr.jar file?
The code for JDK8 was posted by Marcus in an external site:
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import oracle.jrockit.jfr.parser.*;
public class JDKParserTest {
@SuppressWarnings("deprecation")
public static void main(String[] args) throws IOException {
File recordingFile = new File("C:\\demo\\wldf.jfr");
Parser parser = new Parser(recordingFile);
int count = 0;
Iterator<ChunkParser> chunkIter = parser.iterator();
while (chunkIter.hasNext()) {
ChunkParser chunkParser = chunkIter.next();
for (FLREvent event : chunkParser) {
count++;
//System.out.println(event.toString());
}
}
parser.close();
System.out.println("Found " + count + " events");
}
}
That's exactly what I needed to build a custom report. Ref: http://hirt.se/blog/?p=446