diff --git a/src/java.base/share/classes/java/util/regex/Pattern.java b/src/java.base/share/classes/java/util/regex/Pattern.java index 002db861033..7469d5de4d8 100644 --- a/src/java.base/share/classes/java/util/regex/Pattern.java +++ b/src/java.base/share/classes/java/util/regex/Pattern.java @@ -2063,7 +2063,7 @@ loop: for(int x=0, offset=0; x x == 0x0A || x == 0x0B || - x == 0x0C || x == 0x0D || x == 0x85 || x == 0x2028 || - x == 0x2029); - chClass.next = branchConn; - grHead.next = new Branch(slice, chClass, branchConn); - return groupWithClosure(closure(grHead), grHead, grTail, false); - } - /** * Processes repetition. If the next character peeked is a quantifier * then new nodes must be appended to handle the repetition. @@ -4777,8 +4722,8 @@ loop: for(int x=0, offset=0; x= atoms.length) { - int len = ArraysSupport.newLength(size, - 1, /* minimum growth */ - size /* preferred growth */); - atoms = Arrays.copyOf(atoms, len); + Node[] tmp = new Node[atoms.length*2]; + System.arraycopy(atoms, 0, tmp, 0, atoms.length); + atoms = tmp; } atoms[size++] = node; } diff --git a/test/jdk/java/util/regex/RegExTest.java b/test/jdk/java/util/regex/RegExTest.java index 387b01e5f62..a70cf328c3a 100644 --- a/test/jdk/java/util/regex/RegExTest.java +++ b/test/jdk/java/util/regex/RegExTest.java @@ -36,7 +36,7 @@ * 8151481 4867170 7080302 6728861 6995635 6736245 4916384 6328855 6192895 * 6345469 6988218 6693451 7006761 8140212 8143282 8158482 8176029 8184706 * 8194667 8197462 8184692 8221431 8224789 8228352 8230829 8236034 8235812 - * 8216332 8214245 8237599 8241055 8247546 + * 8216332 8214245 8237599 8241055 8247546 8258259 * * @library /test/lib * @library /lib/testlibrary/java/lang @@ -5063,7 +5063,15 @@ public class RegExTest { report("surrogatePairWithCanonEq"); } - // This test is for 8235812 + private static String s2x(String s) { + StringBuilder sb = new StringBuilder(); + for (char ch : s.toCharArray()) { + sb.append(String.format("\\u%04x", (int)ch)); + } + return sb.toString(); + } + + // This test is for 8235812, with cases excluded by 8258259 private static void lineBreakWithQuantifier() { // key: pattern // value: lengths of input that must match the pattern @@ -5073,12 +5081,12 @@ public class RegExTest { Map.entry("\\R+", List.of(1, 2, 3)), Map.entry("\\R{0}", List.of(0)), Map.entry("\\R{1}", List.of(1)), - Map.entry("\\R{2}", List.of(2)), - Map.entry("\\R{3}", List.of(3)), +// Map.entry("\\R{2}", List.of(2)), // 8258259 +// Map.entry("\\R{3}", List.of(3)), // 8258259 Map.entry("\\R{0,}", List.of(0, 1, 2, 3)), Map.entry("\\R{1,}", List.of(1, 2, 3)), - Map.entry("\\R{2,}", List.of(2, 3)), - Map.entry("\\R{3,}", List.of(3)), +// Map.entry("\\R{2,}", List.of(2, 3)), // 8258259 +// Map.entry("\\R{3,}", List.of(3)), // 8258259 Map.entry("\\R{0,0}", List.of(0)), Map.entry("\\R{0,1}", List.of(0, 1)), Map.entry("\\R{0,2}", List.of(0, 1, 2)), @@ -5086,9 +5094,9 @@ public class RegExTest { Map.entry("\\R{1,1}", List.of(1)), Map.entry("\\R{1,2}", List.of(1, 2)), Map.entry("\\R{1,3}", List.of(1, 2, 3)), - Map.entry("\\R{2,2}", List.of(2)), - Map.entry("\\R{2,3}", List.of(2, 3)), - Map.entry("\\R{3,3}", List.of(3)), +// Map.entry("\\R{2,2}", List.of(2)), // 8258259 +// Map.entry("\\R{2,3}", List.of(2, 3)), // 8258259 +// Map.entry("\\R{3,3}", List.of(3)), // 8258259 Map.entry("\\R", List.of(1)), Map.entry("\\R\\R", List.of(2)), Map.entry("\\R\\R\\R", List.of(3)) @@ -5131,7 +5139,7 @@ public class RegExTest { if (!m.reset(in).matches()) { failCount++; System.err.println("Expected to match '" + - in + "' =~ /" + p + "/"); + s2x(in) + "' =~ /" + p + "/"); } } }