8230338: Accurate error message about bad Unicode block name
authorigerasim
Thu, 29 Aug 2019 07:39:06 -0700
changeset 57941 a1a8f8fae7d9
parent 57939 e8ba7e4f4190
child 57942 e29b6ddfd9f4
8230338: Accurate error message about bad Unicode block name Reviewed-by: rriggs
src/java.base/share/classes/java/util/regex/Pattern.java
--- a/src/java.base/share/classes/java/util/regex/Pattern.java	Thu Aug 29 15:59:00 2019 +0200
+++ b/src/java.base/share/classes/java/util/regex/Pattern.java	Thu Aug 29 07:39:06 2019 -0700
@@ -2888,12 +2888,12 @@
                 p = CharPredicates.forUnicodeBlock(name.substring(2));
             } else if (name.startsWith("Is")) {
                 // \p{IsGeneralCategory} and \p{IsScriptName}
-                name = name.substring(2);
-                p = CharPredicates.forUnicodeProperty(name);
+                String shortName = name.substring(2);
+                p = CharPredicates.forUnicodeProperty(shortName);
                 if (p == null)
-                    p = CharPredicates.forProperty(name);
+                    p = CharPredicates.forProperty(shortName);
                 if (p == null)
-                    p = CharPredicates.forUnicodeScript(name);
+                    p = CharPredicates.forUnicodeScript(shortName);
             } else {
                 if (has(UNICODE_CHARACTER_CLASS)) {
                     p = CharPredicates.forPOSIXName(name);
@@ -2902,7 +2902,7 @@
                     p = CharPredicates.forProperty(name);
             }
             if (p == null)
-                throw error("Unknown character property name {In/Is" + name + "}");
+                throw error("Unknown character property name {" + name + "}");
         }
         if (isComplement) {
             // it might be too expensive to detect if a complement of