Closed jcflack closed 1 year ago
Also breaks the DDRProcessor
. Looks like they've changed what regular expressions mean.
Submitted at bugreport.java.com
as published as JDK-8309515:JI-9075361
In addressing issue 8065554 (MatchResult
should provide values of named-capturing groups), commit openjdk/jdk@ce85cac added a namedGroups
field in Matcher
to cache the map from parentPattern.namedGroups()
.
The map is lazily cached, only when the field is null and namedGroups()
is called (which may be indirectly through a call of start(String)
, end(String)
, or group(String)
. The same cached value will then continue to be returned even if Matcher.usePattern
is later called and the new Pattern
has different named groups, or no named groups, or the same named groups mapped to different integers. Therefore, symptoms can include seeing the wrong results when retrieving by named groups, or spurious IllegalArgumentException
s for groups that the new pattern provides, or exceptions not thrown for groups that the new pattern doesn't provide, or exceptions for an invalid group index when calling a method that takes a group name.
Could be fixed by eliminating the local copy and simply having Matcher.namedGroups()
call parentPattern.namedGroups()
unconditionally, or by having Matcher.usePattern
simply null the field, so the correct map will be lazily cached when next needed.
Resolved in 1.6.5 by detecting when affected by this bug and throwing an exception. The message advises to use either a version of Java earlier than 20, or a version recent enough to have JDK-8309515 fixed.
Until a solution for that, well, use Java 19 or earlier.