Hello!

If an error occurred during regexp pattern compilation, PatternSyntaxException.getMessage() can be used to generate a multi-line detailed description. Generally, the description can include a message, the pattern, and the index where the error occurred.

If the pattern is too long, then the description becomes hard to read.
It is proposed to limit the length of the pattern in the description by 80 characters, and truncate it if it is too long.

Here are examples of how the description will look like:


named capturing group <x> does not exist near index 4
\k<x>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[...TRUNCATED]
    ^

named capturing group <x> does not exist near index 105
[TRUNCATED...]aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\k<x>
^

named capturing group <x> does not exist near index 105
[TRUNCATED...]aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\k<x>bbbbbbbbbb
^

named capturing group <x> does not exist near index 105
[TRUNCATED...]aaaaaaaaaaaaaaaaaaaaaa\k<x>bbbbbbbbbbbbbbbbbbbbbbbbb[...TRUNCATED]
                                        ^

Would you please help review the fix?

BUGURL: https://bugs.openjdk.java.net/browse/JDK-8223193
CSR: https://bugs.openjdk.java.net/browse/JDK-8223218
WEBREV: http://cr.openjdk.java.net/~igerasim/8223193/00/webrev/

--
With kind regards,
Ivan Gerasimov

Reply via email to