You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Submitted at bugreport.java.com as JI-9075361 published as JDK-8309515:
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 IllegalArgumentExceptions 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.
Activity
jcflack commentedon May 30, 2023
Also breaks the
DDRProcessor. Looks like they've changed what regular expressions mean.DDRProcessor tests ok with Java 19
jcflack commentedon Jun 5, 2023
Submitted at
bugreport.java.comaspublished as JDK-8309515:JI-9075361In addressing issue 8065554 (
MatchResultshould provide values of named-capturing groups), commit openjdk/jdk@ce85cac added anamedGroupsfield inMatcherto cache the map fromparentPattern.namedGroups().The map is lazily cached, only when the field is null and
namedGroups()is called (which may be indirectly through a call ofstart(String),end(String), orgroup(String). The same cached value will then continue to be returned even ifMatcher.usePatternis later called and the newPatternhas 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 spuriousIllegalArgumentExceptions 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()callparentPattern.namedGroups()unconditionally, or by havingMatcher.usePatternsimply null the field, so the correct map will be lazily cached when next needed.Private methods to bypass buggy namedGroups cache
Private methods to bypass buggy namedGroups cache
Merge into REL1_6_STABLE these pull requests:
jcflack commentedon Jun 13, 2023
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.