RFR: JDK-8253641: Missing newline in PrettyWriter::printClassLoader if classloader is null. [v2]
Michael Bien
github.com+114367+mbien at openjdk.java.net
Tue Oct 20 13:43:35 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
Michael Bien has refreshed the contents of this pull request, and previous commits have been removed. The incremental
views will show differences compared to the previous content of the PR. The pull request contains two new commits since
the last revision:
- small refactoring: merged two if blocks in PrettyWriter::printClassLoader.
- bugfix: Missing newline in PrettyWriter::printClassLoader if classloader is null.
-------------
Changes:
- all: https://git.openjdk.java.net/jdk/pull/248/files
- new: https://git.openjdk.java.net/jdk/pull/248/files/67750e2b..1cc20517
Webrevs:
- full: https://webrevs.openjdk.java.net/?repo=jdk&pr=248&range=01
- incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=248&range=00-01
Stats: 5 lines in 1 file changed: 2 ins; 1 del; 2 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