RFR: JMC-6149: Distinguish by package with default packages in the traces does not work

Alex Macdonald almacdon at redhat.com
Mon Dec 3 15:22:55 UTC 2018


This patch addresses JMC-6149 [0], in which the stack trace tree disappears
when a default package is encountered when selecting the option
"Distinguish Frames by Package". For testing purposes, I have been using
the memoryleak.jfr recording that is available as an attachment on JMC-6127

The problem here is a NPE being thrown when checking whether if the
category object equals the cached lastCategory object [2]. If the current
frame has no corresponding package then the package attribute will be null
[3], which then causes "category" to be null.

In StructTypes.java [4], there are precautions in place for handling
unknown methods and classes [5] so null values aren't passed around, but
nothing in place to handle unknown packages. This patch introduces a null
check in the IMCType implementation to mimic how the method [6] and class
[7] implementations currently handle null values. Additionally, a null
check must be made in the convertNames() and getName() methods that access
the package name, because if it is null then the
MethodToolkit.refTypeToBinaryJLS() [8] will throw an NPE when trying to get
the length of the name.

I've taken a couple screenshots to show the before and after of this patch,
as well as a couple gifs to show how to reproduce the behaviour. Link to
imgur album: https://imgur.com/a/0hNekjh

Before (image): https://imgur.com/VnvwMkQ
Before (gif): https://imgur.com/gZcPDCF
After (image): https://imgur.com/TOyalSG
After (gif): https://imgur.com/7GaCMII




[0] https://bugs.openjdk.java.net/browse/JMC-6149
[1] https://bugs.openjdk.java.net/browse/JMC-6127
[3] https://imgur.com/ktUJvo5
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 6149-0.patch
Type: text/x-patch
Size: 1977 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/jmc-dev/attachments/20181203/162d338d/6149-0.patch>

More information about the jmc-dev mailing list