Skip to content

Commit 28e40c5

Browse files
committed
[GR-42699] Review and update the Build and Run Native Executables with JFR guide.
PullRequest: graal/13281
2 parents 4c92891 + 75e753b commit 28e40c5

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

docs/reference-manual/native-image/guides/build-and-run-native-executable-with-jfr.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ permalink: /reference-manual/native-image/guides/build-and-run-native-executable
88
# Build and Run Native Executables with JFR
99

1010
JDK Flight Recorder (JFR) is a tool for collecting diagnostic and profiling data about a running Java application, built into a JVM.
11-
GraalVM Native Image supports JFR events and users can use [`jdk.jfr.Event`](https://docs.oracle.com/en/java/javase/11/docs/api/jdk.jfr/jdk/jfr/Event.html) API with a similar experience to using JFR in the Java HotSpot VM.
11+
GraalVM Native Image supports JFR events and users can use the [`jdk.jfr.Event`](https://docs.oracle.com/en/java/javase/11/docs/api/jdk.jfr/jdk/jfr/Event.html) API with a similar experience to using JFR in the Java HotSpot VM.
1212

13-
To record JFR events when running a native executable, JFR support and JFR recording must be enabled, and this guide covers how to do that.
13+
To record JFR events when running a native executable, enable JFR support and JFR recording as described in this guide.
1414

15-
> Note: JFR events recording is not supported on GraalVM JDK for Windows. JFR is only supported with native executables built on GraalVM JDK 11.
15+
> Note: JFR event recording is not supported on GraalVM JDK for Windows.
1616
1717
## Enable JFR Support and Record Events at Run Time
1818

@@ -23,7 +23,13 @@ To build a native executable with the JFR events support, you first need to add
2323

2424
Follow the steps below to practice building a native executable with JFR support and recording events at run time.
2525

26-
1. Save the following code to the file named _JFRDemo.java_.
26+
> Note: You are expected to have GraalVM installed with Native Image support. The easiest way to install GraalVM is to use the [GraalVM JDK Downloader](https://github.com/graalvm/graalvm-jdk-downloader).
27+
28+
1. Install VisualVM by running:
29+
```bash
30+
gu install visualvm
31+
```
32+
2. Save the following code to the file named _JFRDemo.java_.
2733

2834
```java
2935
import jdk.jfr.Event;
@@ -51,31 +57,31 @@ Follow the steps below to practice building a native executable with JFR support
5157
It creates an event, labelled with the `@Label` annotation from the `jdk.jfr.*` package.
5258
If you run this application, it will not print anything and just run that event.
5359

54-
2. Compile the Java file on GraalVM JDK:
60+
3. Compile the Java file using the GraalVM JDK:
5561
```shell
5662
$JAVA_HOME/bin/javac JFRDemo.java
5763
```
5864
It creates two class files: `JFRDemo$HelloWorldEvent.class` and `JFRDemo.class`.
5965

60-
3. Build a native executable with the VM inspection enabled:
66+
4. Build a native executable with the VM inspection enabled:
6167
```shell
6268
$JAVA_HOME/bin/native-image --enable-monitoring=jfr JFRDemo
6369
```
6470
The `--enable-monitoring=jfr` option enables features such as JFR that can be used to inspect the VM.
6571

66-
4. Run the executable and start recording:
72+
5. Run the executable and start recording:
6773
```shell
6874
./jfrdemo -XX:StartFlightRecording="filename=recording.jfr"
6975
```
70-
It runs the application as a native executable. The `-XX:StartFlightRecording` option enables the built-in Flight Recorder and starts recording to a specified binary file, `recording.jfr`.
76+
This command runs the application as a native executable. The `-XX:StartFlightRecording` option enables the built-in Flight Recorder and starts recording to a specified binary file, _recording.jfr_.
7177

72-
5. Start [VisualVM](https://visualvm.github.io/) to view the contents of the recording file in a user-friendly way. GraalVM provides VisualVM in the core installation. To start the tool, run:
78+
6. Start [VisualVM](https://visualvm.github.io/) to view the contents of the recording file in a user-friendly way. GraalVM provides VisualVM in the core installation. To start the tool, run:
7379

7480
```shell
75-
$JAVA_HOME/bin/jvisualvm
81+
$JAVA_HOME/bin/visualvm
7682
```
7783

78-
6. Go to **File**, then **Add JFR Snapshot**, browse _recording.jfr_, and open the selected file. Confirm the display name and click **OK**.
84+
7. Go to **File**, then **Add JFR Snapshot**, browse _recording.jfr_, and open the selected file. Confirm the display name and click **OK**.
7985
Once opened, there is a bunch of options you can check: Monitoring, Threads, Exceptions, etc., but you should be mostly interested in the events browsing. It will look something like this:
8086

8187
![JDK Flight Recorder](img/jfr.png)
@@ -85,7 +91,7 @@ Follow the steps below to practice building a native executable with JFR support
8591
```shell
8692
$JAVA_HOME/bin/jfr print recording.jfr
8793
```
88-
It prints all events recorded by Flight Recorder.
94+
It prints all the events recorded by Flight Recorder.
8995

9096
### Related Documentation
9197

0 commit comments

Comments
 (0)