RFR: 8298128: runtime/ErrorHandling/TestSigInfoInHsErrFile.java fails to find pattern with slowdebug [v2]
David Holmes
dholmes at openjdk.org
Sun Dec 18 21:36:51 UTC 2022
On Sun, 18 Dec 2022 17:58:38 GMT, Afshin Zafari <duke at openjdk.org> wrote:
>> test/hotspot/jtreg/runtime/ErrorHandling/HsErrFileUtils.java line 138:
>>
>>> 136: throw new RuntimeException("hs-err file incomplete (first missing pattern: " + currentPositivePattern.pattern() + ")");
>>> 137: } else {
>>> 138: // Impossible to reach here, where stack is not empty and currentPositivePattern which was peeked from stack is null.
>>
>> If this is impossible to reach then why put in the null check? If the impossible were to happen you would get a NPE.
>
> `currentPositivePattern` is null checked before any usage. Therefore, the other parts of the code are guarded against NPE.
> For using `currentPositivePattern`, I should also check it against `null`. Then, the `else { ...} ` part became unreachable. I just put this part for future contributors. Maybe the comments only are enough for that.
> What is better: remove else part? or improve the comments? or both?
IMO all you need here is simply:
// Found all positive pattern?
if (!positivePatternStack.isEmpty()) {
throw new RuntimeException("hs-err file incomplete (first missing pattern: " + currentPositivePattern.pattern() + ")");
}
-------------
PR: https://git.openjdk.org/jdk/pull/11704
More information about the hotspot-dev
mailing list