JFR version 0.9 support

Questions about YourKit Java Profiler
Post Reply
brunoantunes
Posts: 3
Joined: Tue Oct 12, 2021 10:42 am

JFR version 0.9 support

Post by brunoantunes »

When opening Java Fligth Recording creating using Java SE 8, we get following error:

"File version 0.9. Only Flight Recorder files of version 1.x and 2.x can be read by this JDK"

Using Your Kit Java Profiler 2021.11-b172

regards
--
Bruno Antunes
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: JFR version 0.9 support

Post by Anton Katilin »

Hi Bruno,

What is the exact Java version?

Best regards,
Anton
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: JFR version 0.9 support

Post by Anton Katilin »

Update:

We would appreciate if you could share an example of such .jfr file. Please zip and send attached to [email protected]
brunoantunes
Posts: 3
Joined: Tue Oct 12, 2021 10:42 am

Re: JFR version 0.9 support

Post by brunoantunes »

I can upload java flight recording, but this can be generated on the fly with any application running, at least with Oracle Java SE 8

Test using Oracle JDK 8 Update 281
# java -version
java version "1.8.0_281"
Java(TM) SE Runtime Environment (build 1.8.0_281-b32)
Java HotSpot(TM) 64-Bit Server VM (build 25.281-b32, mixed mode)

Start some application with this version. An example using "jd-gui"
# java -XX:+UnlockCommercialFeatures -XX:+FlightRecorder -jar jd-gui-1.6.6.jar

Perform some recording
# jcmd <PID HERE> JFR.start duration=1m filename=flight.jfr

Try to open generated recording on YourKit and the error will happen.
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: JFR version 0.9 support

Post by Anton Katilin »

Thank you for the instructions.

We repeated the steps with OpenJDK Java 8 (not Oracle JDK). The produced JFR file has appropriate supported format.

Please try doing the same with OpenJDK Java 8.

With OpenJDK -XX:+FlightRecorder works without -XX:+UnlockCommercialFeatures too.
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: JFR version 0.9 support

Post by Anton Katilin »

It's a problem of the combination Java 8 + Oracle JDK:
- OpenJDK Java 8 is OK;
- Java 11 or newer, either Oracle JDK or OpenJDK, is OK too.
brunoantunes
Posts: 3
Joined: Tue Oct 12, 2021 10:42 am

Re: JFR version 0.9 support

Post by brunoantunes »

We can open that recording in JDK Mission Control (tested with versions 7.1.2, 8 and 8.1) but not on YourKIt.

Tested also executing YourKit with Oracle JDK 11, but the reported error still happens

If we perform execution and recording with OpenJDK 8, Java 11 or newer (Oracle JDK or OpenJDK) YourKIt can read the file.

best regards,
--
Bruno Antunes
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: JFR version 0.9 support

Post by Anton Katilin »

Hello Bruno,

The problem is solely in Oracle JDK Java 8. It creates .jfr files of version 0.9 which is incompatible with the JFR API used by YourKit Java Profiler.

The API is the proper, recommended way to deal with .jfr files.

JFR was integrated to Java 11 via https://openjdk.java.net/jeps/328 which encourages to use the API instead of parsing the files directly: "The binary data format is not to be used directly as it is subject to change. Instead, APIs will be provided for interacting with recording files."

The JFR API has been introduced in Java 11. It is available in any Java 11+.

Therefore it does not matter on what JDK you run YourKit Java Profiler. The JFR API is same in OpenJDK and Oracle Java, it is never able to open v0.9 files. It supports versions 1.x and 2.x instead.

Apparently the JMC does not use the API at least for loading v0.9 files. Instead, it must be using an internal implementation for loading this file format.

It seems there is no other way to support the version 0.9 format in YourKit Java Profiler or in any other tool which is not JMC or a derived work than to write a custom parser. We definitely will not be able to fit this task into the upcoming version 2021.11 schedule.

Fortunately, workarounds to this problem exist. If you need Java 8, use OpenJDK instead of Oracle JDK. If you can use Java 11 or newer, there is no problem at all: both Oracle and OpenJDK produce the API-compatible output. So the problem is a legacy of JFR being a closed, commercial feature before Java 11.

Best regards,
Anton
dugish1
Posts: 1
Joined: Thu Oct 21, 2021 5:29 am

Re: JFR version 0.9 support

Post by dugish1 »

With your permission, we'd like to also ask:
Can we use newer versions beyond java version "1.8.0_281", or do we have a risk it won't work smoothly?
Thanks
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: JFR version 0.9 support

Post by Anton Katilin »

The described difference between Java 8 Oracle JDK and OpenJDK exists in newest Java 8 builds too.
Post Reply