3

Following this post :

jfr is supported natively in openjdk 11

and it is confirmed by the features list of OpenJDK 11:

328: Flight Recorder

However, from this DZone article, about using JFR-linked option -XX:+UnlockCommercialFeatures:

OpenJDK doesn’t recognize this option

And when I try for ex. with Gradle: ./gradlew clean -Dorg.gradle.jvmargs="-XX:+UnlockCommercialFeatures" I get

Process command line: C:\Program Files\AdoptOpenJDK\jdk-11.0.11.9-hotspot\bin\java.exe -XX:+UnlockCommercialFeatures (...)

Unrecognized VM option 'UnlockCommercialFeatures'

What am I missing here ?

ThCollignon
  • 976
  • 3
  • 14
  • 31

1 Answers1

8

JFR was a commercial feature in Oracle Java up to Java 1.8 that needed to be specially enabled (using -XX:+UnlockCommercialFeatures).

With Java 11 and later it is no longer a commercial feature so you don't need this flag.

Actually the linked article states:

JFR Packaging Differences
Oracle JDK 11 emits a warning when using the -XX:+UnlockCommercialFeatures option, whereas OpenJDK doesn’t recognize this option and reports an error.

And the example below that the author shows doesn't use the -XX:+UnlockCommercialFeatures.

Thomas Kläger
  • 17,754
  • 3
  • 23
  • 34
  • No more error, thanks. A side question just in case: I run `./gradlew -Dorg.gradle.jvmargs="-XX:+FlightRecorder -XX:StartFlightRecording=duration=30s,filename=my_recording.jfr -XX:FlightRecorderOptions=stackdepth=256" clean` and no .jfr file is created, what could be the cause ? – ThCollignon Nov 16 '21 at 12:09
  • 1
    @Coli I think it is created - it is just not at the place where you are looking for it. When starting gradle this it the FlightRecorder-Option applies to the gradle daemon and the gradle daemon has its working directory somewhere like `~/.gradle/daemon/` – Thomas Kläger Nov 16 '21 at 13:18
  • Found it, thanks. – ThCollignon Nov 16 '21 at 14:00