--- old/src/java.base/share/classes/jdk/internal/module/Checks.java 2017-03-21 13:44:07.018695592 +0000 +++ new/src/java.base/share/classes/jdk/internal/module/Checks.java 2017-03-21 13:44:06.821682073 +0000 @@ -180,41 +180,38 @@ } /** - * Returns {@code true} if the last character of the given name is legal - * as the last character of a module name. - * - * @throws IllegalArgumentException if name is empty + * Returns {@code true} if a given legal module name contains an identifier + * that doesn't end with a Java letter. */ - public static boolean hasLegalModuleNameLastCharacter(String name) { - if (name.isEmpty()) - throw new IllegalArgumentException("name is empty"); - int len = name.length(); - if (isASCIIString(name)) { - char c = name.charAt(len-1); - return Character.isJavaIdentifierStart(c); - } else { - int i = 0; - int cp = -1; - while (i < len) { - cp = name.codePointAt(i); - i += Character.charCount(cp); + public static boolean hasJavaIdentifierWithTrailingDigit(String name) { + // quick scan to allow names that are just ASCII without digits + boolean needToParse = false; + int i = 0; + while (i < name.length()) { + int c = name.charAt(i); + if (c > 0x7F || (c >= '0' && c <= '9')) { + needToParse = true; + break; } - return Character.isJavaIdentifierStart(cp); + i++; } - } + if (!needToParse) + return false; - /** - * Returns true if the given string only contains ASCII characters. - */ - private static boolean isASCIIString(String s) { - int i = 0; - while (i < s.length()) { - int c = s.charAt(i); - if (c > 0x7F) - return false; - i++; + // slow path + int next; + int off = 0; + while ((next = name.indexOf('.', off)) != -1) { + int last = isJavaIdentifier(name, off, (next - off)); + if (!Character.isJavaIdentifierStart(last)) + return true; + off = next+1; } - return true; + int last = isJavaIdentifier(name, off, name.length() - off); + if (!Character.isJavaIdentifierStart(last)) + return true; + return false; + } /**