Can JFR files once printed as Json be compiled back to .jfr format

293 Views Asked by At

I have JSON file that I created using the jfr print --json command, will I be able to convert them back into an .jfr file?

1

There are 1 best solutions below

0
On BEST ANSWER

There is no support in the JDK to convert a JSON printout into the binary recording format, and I'm not aware of any third-party tool that can do it. The binary file format is undocumented and it would require lots of processing to compress it back into its original form.

If you want to filter out events or scrub a recording, it's possible from JDK 19, both from command line and programmatically.

$ jfr scrub --exclude-events 
  InitialEnvironmentVariable recording.jfr no-psw.jfr

For JDKs prior to JDK 19, the best you can do is to turn off the events you don't want. In JDK 17, you can do that from command line:

$ java -XX:StartFlightRecording:
        jdk.InitialEnvironmentVariable#enabled=false ...

For JDK 16, or earlier, you need to create custom .jfc file.