On Tue, 4 Nov 2025 11:56:52 GMT, Ioi Lam <[email protected]> wrote:

>> In the previous fix (https://github.com/openjdk/jdk/pull/28035), I added 
>> `OutputAnalyzer::match(String regexp)`, but it uses `String.matches()` which 
>> has different semantics than the existing "match" functions such as 
>> `OutputAnalyzer::shouldMatch()`. 
>> 
>> `String.matches()` is a poor choice for matching the stdout/stderr in 
>> `OutputAnalyzer`:
>> 
>> - It requires a full match, so you need to use 
>> `haystackString.matches(".*needle.*")`
>> - But `.*` doesn't match across newlines, so it's basically useless for most 
>> program output.
>> 
>> That's why the pattern in the previous fix in 
>> AccessZeroNKlassHitsProtectionZone.java 
>> (https://github.com/openjdk/jdk/pull/28035)  doesn't work:
>> 
>> https://github.com/openjdk/jdk/blame/e4aed95cac343f1339b9bc87721561bdc4c2f5ad/test/hotspot/jtreg/runtime/ErrorHandling/AccessZeroNKlassHitsProtectionZone.java#L146
>> 
>> I fixed this by re-working `OutputAnalyzer::match()`, etc, to do the same 
>> thing as `OutputAnalyzer::shouldMatch()`.  I also refactored the code to 
>> consolidate most of the regexp handling code to the two `matchesHelper()` 
>> methods.
>
> Ioi Lam has updated the pull request incrementally with one additional commit 
> since the last revision:
> 
>   Use String... as suggested by @stefank

Marked as reviewed by stefank (Reviewer).

Looks good.

-------------

PR Review: https://git.openjdk.org/jdk/pull/28077#pullrequestreview-3422216751
PR Comment: https://git.openjdk.org/jdk/pull/28077#issuecomment-3491355552

Reply via email to