jfr.dcmd log is not shown
Yasumasa Suenaga
yasuenag at gmail.com
Tue Oct 23 15:10:29 UTC 2018
Hi all,
I tried to check arguments of -XX:StartFlightRecording via -Xlog:jfr+dcmd=debug , but I couldn't.
jfr.dcmd log will be shown from DCmdStart::execute, but I think it has two problems:
1. Log level will be not set before showing log.
LogTag::tagSetLevel is used to decide to show the log. But it will be set in
JNI code which is called by JVM::<clinit>. JVM class is not loaded when
DCmdStart::execute tries to show log.
2. `settings` might be null, so NPE will occur when DCmdStart::execute tries to
show log.
IMHO they can be fixed with following patch. Can I file this problem to JBS and send a webrev?
(I'm a Committer of jdk project)
---------------------
diff -r eadd0abbfdf4 src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java Tue Oct 23 13:24:36 2018 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java Wed Oct 24 00:10:05 2018 +0900
@@ -34,6 +34,7 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
+import java.util.Objects;
import jdk.jfr.FlightRecorder;
import jdk.jfr.Recording;
@@ -81,9 +82,12 @@
*/
@SuppressWarnings("resource")
public String execute(String name, String[] settings, Long delay, Long duration, Boolean disk, String path, Long maxAge, Long maxSize, Boolean dumpOnExit, Boolean pathToGcRoots) throws DCmdException {
+ if (!JVM.getJVM().isAvailable()) {
+ throw new DCmdException("JFR is not available");
+ }
if (LogTag.JFR_DCMD.shouldLog(LogLevel.DEBUG)) {
Logger.log(LogTag.JFR_DCMD, LogLevel.DEBUG, "Executing DCmdStart: name=" + name +
- ", settings=" + Arrays.asList(settings) +
+ ", settings=" + Arrays.asList(Objects.requireNonNullElse(settings, new String[0])) +
", delay=" + delay +
", duration=" + duration +
", disk=" + disk+
---------------------
Thanks,
Yasumasa
More information about the hotspot-jfr-dev
mailing list