RFR: 8065554: MatchResult should provide values of named-capturing groups
Daniel Fuchs
dfuchs at openjdk.org
Wed Aug 24 17:36:21 UTC 2022
On Wed, 24 Aug 2022 16:12:52 GMT, Raffaello Giulietti <duke at openjdk.org> wrote:
>> src/java.base/share/classes/java/util/regex/MatchResult.java line 274:
>>
>>> 272: * might be preferable for other reasons.
>>> 273: *
>>> 274: * @since 20
>>
>> Should the method declare that it throws `UnsupportedOperationsExceptions`?
>> Because that is what will happen if `namedGroups` is not overridden/implemented.
>>
>> Same comment for the other new methods.
>
> Not sure.
> If the convention is to document every single `RuntimeException` that methods invoked by this one could throw, then yes.
> In other words, should `RuntimeExcpetion`s thrown deep in an invocation stack be documented in every caller method?
In principle, yes. In practice, I see that `namedGroups` doesn't have an `@throws UnsupportedOperationException` but has an `@implSpec` that says that the default implementation throws `UnsupportedOperationException`. This seems strange to me - maybe @stuart-marks or @jddarcy can comment.
What I was hinting at here however is that we might want to extend the `@implSpec` of the new methods to note that these method will throw `UnsuportedOperationException` if `namedGroups` is not implemented (like the `@implSpec` of `namedGroups` does).
-------------
PR: https://git.openjdk.org/jdk/pull/10000
More information about the core-libs-dev
mailing list