On Thu, 25 Aug 2022 09:24:20 GMT, Raffaello Giulietti <[email protected]> wrote:
>> Add support for named groups to java.util.regex.MatchResult
>
> Raffaello Giulietti has updated the pull request incrementally with one
> additional commit since the last revision:
>
> 8065554: MatchResult should provide values of named-capturing groups
src/java.base/share/classes/java/util/regex/MatchResult.java line 111:
> 109: * The default implementation of this method throws
> 110: * {@link UnsupportedOperationException} if {@link #namedGroups()}
> is not
> 111: * overridden.
The essential thing for `@implSpec` is to describe "self-use" of methods on
this object. This is important for subclassers to know whether they can inherit
the default implementation or whether they should override it. It looks like
`start(String)` does the following:
- calls namedGroups() to obtain a mapping from group names to group numbers,
propagating UOE if namedGroups() throws it
- if `name` is not present in the group map, throws IAE
- calls `start()` on the group number obtained from the map, and returns that
value
I don't think we need to go to the level of detail about whether `get` or
`containsKey` is called on the map, but I think the self-calls to
`namedGroups()` and `start(int)` are important.
Similar comments apply to the `@implSpec` comments of `end(String)` and
`group(String)`.
-------------
PR: https://git.openjdk.org/jdk/pull/10000