Fix jdk.jfr module resolution for JFR V2 startup and jcmd - #24714
Conversation
Can you provide more details about the failure or the assertion, or is there any issue reference?
|
2d0489d to
28b8acd
Compare
28b8acd to
35f6509
Compare
On the assertion / failure details:
So, with ...
jfrEventClass = internalFindClassUTF8(currentThread, "**jdk/jfr/Event**", ..., vm->systemClassLoader, 0);
Assert_VM_notNull(jfrEventClass); --> **crashes here**
...
On jcmd and the JFR dependency: |
Thanks the detailed analysis @tomal-majumder
In this case, please update the commit message to remove |
35f6509 to
676180c
Compare
Thanks for the suggestion! Commit message updated! |
676180c to
f8ec99e
Compare
JFR V2 (gated behind -XX:+EnableOpenJ9ExperimentalFlightRecording on JDK17) assumed jdk.jfr was always resolved before touching any of its classes. That breaks for a --module launch whose module declares no "requires jdk.jfr", and for a JFR diagnostic command (JFR.start/stop/dump via jcmd) executed after boot with no -XX:StartFlightRecording on the original command line. Both exercised by test/jdk/jdk/jfr/jvm/TestModularImage.java, which failed several ways: the "Started recording" print was silently dropped, a native assertion crashed the VM when jdk.jfr was not resolved already (e.g. --add-mods jdk.jfr not given at launch), and a module-resolution failure printed the wrong text. This introduces the following changes: - Default LogTag.JFR_START to INFO instead of WARN, and tag the startup banner with it (was tagged as plain LogTag.JFR), so it is no longer filtered by the default logging threshold. - Inject jdk.jfr into the root module set at boot when -XX:StartFlightRecording is given with JFR V2 enabled, via a synthesized jdk.module.addmods.<n> property. Extracted the shared injection logic into one addRequiredModuleProperty() helper, reused by two other existing call sites. - Add ensureJfrModuleAvailable(): when a JFR diagnostic command needs jdk.jfr, but nothing requested it at startup, checks the boot layer, then loads jdk.jfr on demand. JFR internal structures now only initialize on success, removing a native assertion crash. The diagnostic command entry points check this and return a clean error instead of failing in reflection. - Print a leading error line in ClassLoader.java's module bootstrap catch block, matching the boot-layer error text TestModularImage.java expects. Signed-off-by: Tomal Majumder <tomal.majumder@ibm.com>
f8ec99e to
7529ccb
Compare
|
jenkins test sanity,extended.functional alinux64 jdk17,jdk21 |
|
jenkins compile win jdk11,jdk17 |
|
jenkins test sanity aix jdk17 |
JFR V2 (gated behind
-XX:+EnableOpenJ9ExperimentalFlightRecordingon JDK17) assumed
jdk.jfrwas always resolved before touching anyof its classes. That breaks for a
--modulelaunch whose moduledeclares no "requires jdk.jfr", and for a jcmd
JFR.startwith no-XX:StartFlightRecordingon the command line. Both exercised bytest/jdk/jdk/jfr/jvm/TestModularImage.java, which failed severalways: the "Started recording" print was silently dropped, a native
assertion crashed the VM when jdk.jfr was not resolved already
(e.g. -
-add-mods jdk.jfrnot given at launch), and a module-resolutionfailure printed the wrong text.
This introduces the following changes:
Default
LogTag.JFR_STARTto INFO instead of WARN, and tag thestartup banner with it (was tagged as plain LogTag.JFR), so it
is no longer filtered by the default logging threshold.
Inject
jdk.jfrinto the root module set at boot when-XX:StartFlightRecordingis given with JFR V2 enabled, via asynthesized
jdk.module.addmods.<n>property. Extracted theshared injection logic into one
addRequiredModuleProperty()helper, reused by two other existing call sites.
Add
ensureJfrModuleAvailable(): forjcmdwith no-XX:StartFlightRecordingon the command line, checks the bootlayer, then loads
jdk.jfron demand since nothing requested itat startup. JFR internal structures now only initialize on
success, removing a native assertion crash. jcmd DCmd entry
points check this and return a clean error instead of failing
in reflection.
Print a leading error line in
ClassLoader.java's modulebootstrap catch block, matching the boot-layer error text
TestModularImage.java expects.
Fixes: #23708