RFR: 8253641: Missing newline in PrettyWriter::printClassLoader if classloader is null.
Michael Bien
github.com+114367+mbien at openjdk.java.net
Fri Sep 25 12:53:37 UTC 2020
Trivial fix which adds a missing new line to PrettyWriter::printClassLoader if clazz == null.
PrettyWriter is used for both the jfr CLI tool and also for the impl of the public JFR API behind
jdk.jfr.Event::toString().
how to reproduce using JFR CLI:
To generate a JFR dump for testing, simply start HelloWorld.java
public class HelloWorld {
public static void main(String[] args) {System.out.println("hello there");}
}
with
`jdk-15+36/bin/java -XX:StartFlightRecording=filename=dump.jfr,dumponexit=true HelloWorld.java`
current result for events where the classLoader field equals null (note: newline missing):
jdk-15+36/bin/jfr print --events jdk.ModuleRequire dump.jfr
...
jdk.ModuleRequire {
startTime = 16:12:43.524
source = {
name = "jdk.nio.mapmode"
version = "15"
location = "jrt:/jdk.nio.mapmode"
classLoader = null }
requiredModule = {
name = "java.base"
version = "15"
location = "jrt:/java.base"
classLoader = null }
}
...
after the patch, using same jfr dump and displaying the same event:
jdk16/build/linux-x86_64-server-release/jdk/bin/jfr print --events jdk.ModuleRequire dump.jfr
...
jdk.ModuleRequire {
startTime = 16:12:43.524
source = {
name = "jdk.nio.mapmode"
version = "15"
location = "jrt:/jdk.nio.mapmode"
classLoader = null
}
requiredModule = {
name = "java.base"
version = "15"
location = "jrt:/java.base"
classLoader = null
}
}
...
sidenote:
There would be an opportunity to merge the two sequential if-else blocks[1] in printClassLoader over the clazz variable
after this patch, but this would obfuscate the actual bug fix, so I decided to omit it. Let me know if I should add
that. [1]
https://github.com/mbien/jdk/blob/67750e2b599b3f2a6b814d7bceada785ca4051f9/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/PrettyWriter.java#L440-L448
-------------
Commit messages:
- bugfix: Missing newline in PrettyWriter::printClassLoader if classloader is null.
Changes: https://git.openjdk.java.net/jdk/pull/248/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=248&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8253641
Stats: 2 lines in 1 file changed: 2 ins; 0 del; 0 mod
Patch: https://git.openjdk.java.net/jdk/pull/248.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/248/head:pull/248
PR: https://git.openjdk.java.net/jdk/pull/248
More information about the hotspot-jfr-dev
mailing list