RFR: 8370975: OutputAnalyzer.matches() should use Matcher with Pattern.MULTILINE [v2]

Stefan Karlsson stefank at openjdk.org
Tue Nov 4 13:47:11 UTC 2025


On Tue, 4 Nov 2025 11:53:05 GMT, Ioi Lam <iklam at openjdk.org> wrote:

> > > I didn't use "find", as all the existing methods in OutputAnalyzer use "match".
> > 
> > 
> > My point is that you can't have a function called "matches" that performs a "find" instead of a "matches":
> > ```
> >     private boolean matchesHelper(String s, Pattern pattern) {
> >         return s != null && pattern.matcher(s).find();
> >     }
> > ```
> > 
> > 
> >     
> >       
> >     
> > 
> >       
> >     
> > 
> >     
> >   
> > That's too confusing.
> 
> Thanks for the clarification. I've updated the code using your suggestion.

You need to make sure that the code has sensible throughout the library, not only the functions you introduce. There's still a function that uses "find" that has a name including "matches":

    public boolean stdoutMatches(String regexp) {
        return findPattern(regexp, getStdout());
    }

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

PR Comment: https://git.openjdk.org/jdk/pull/28077#issuecomment-3486079517


More information about the hotspot-runtime-dev mailing list