8202771: Migrate Unicode character tests to JDK Repo

Reviewed-by: naoto
diff --git a/test/jdk/java/lang/Character/CharPropTest.java b/test/jdk/java/lang/Character/CharPropTest.java
new file mode 100644
index 0000000..c8a3985
--- /dev/null
+++ b/test/jdk/java/lang/Character/CharPropTest.java
@@ -0,0 +1,288 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8202771
+ * @summary Check j.l.Character.isDigit/isLetter/isLetterOrDigit/isSpaceChar
+ * /isWhitespace/isTitleCase/isISOControl/isIdentifierIgnorable
+ * /isJavaIdentifierStart/isJavaIdentifierPart/isUnicodeIdentifierStart
+ * /isUnicodeIdentifierPart
+ * @run main CharPropTest
+ */
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.stream.Stream;
+
+public class CharPropTest {
+    private static int diffs = 0;
+    private static int rangeStart = 0x0000;
+    private static boolean isRange = false;
+
+    public static void main(String[] args) throws Exception {
+        Path path = Paths.get(System.getProperty("test.src", "."),
+                "UnicodeData.txt");
+        try (Stream<String> lines = Files.lines(path)) {
+            lines.map(String::trim)
+                 .filter(line -> line.length() != 0 && line.charAt(0) != '#')
+                 .forEach(line -> handleOneLine(line));
+
+            if (diffs != 0) {
+                throw new RuntimeException("Total differences: " + diffs);
+            }
+        }
+    }
+
+    private static void handleOneLine(String line) {
+        String[] fields = line.split(";");
+        int currentCp = Integer.parseInt(fields[0], 16);
+        String name = fields[1];
+        String category = fields[2];
+
+        // Except single code point, also handle ranges like the following:
+        // 3400;<CJK Ideograph Extension A, First>;Lo;0;L;;;;;N;;;;;
+        // 4DB5;<CJK Ideograph Extension A, Last>;Lo;0;L;;;;;N;;;;
+        if (isRange) {
+            if (name.endsWith("Last>")) {
+                for (int cp = rangeStart; cp <= currentCp; cp++) {
+                    testCodePoint(cp, category);
+                }
+            } else {
+                throw new RuntimeException("Not a valid range, first range <"
+                        + Integer.toHexString(rangeStart) + "> without last.");
+            }
+            isRange = false;
+        } else {
+            if (name.endsWith("First>")) {
+                rangeStart = currentCp;
+                isRange = true;
+            } else {
+                testCodePoint(currentCp, category);
+            }
+        }
+    }
+
+    private static void testCodePoint(int codePoint, String category) {
+        isDigitTest(codePoint, category);
+        isLetterTest(codePoint, category);
+        isLetterOrDigitTest(codePoint, category);
+
+        isSpaceCharTest(codePoint, category);
+        isWhitespaceTest(codePoint, category);
+
+        isTitleCaseTest(codePoint, category);
+
+        isISOControlTest(codePoint);
+
+        isIdentifierIgnorableTest(codePoint, category);
+        isJavaIdentifierStartTest(codePoint, category);
+        isJavaIdentifierPartTest(codePoint, category);
+        isUnicodeIdentifierStartTest(codePoint, category);
+        isUnicodeIdentifierPartTest(codePoint, category);
+    }
+
+    private static void isDigitTest(int codePoint, String category) {
+        boolean actual = Character.isDigit(codePoint);
+        boolean expected = category.equals("Nd");
+        if (actual != expected) {
+            printDiff(codePoint, "isDigit", actual, expected);
+        }
+    }
+
+    private static void isLetterTest(int codePoint, String category) {
+        boolean actual = Character.isLetter(codePoint);
+        boolean expected = isLetter(category);
+        if (actual != expected) {
+            printDiff(codePoint, "isLetter", actual, expected);
+        }
+    }
+
+    private static void isLetterOrDigitTest(int codePoint, String category) {
+        boolean actual = Character.isLetterOrDigit(codePoint);
+        boolean expected = isLetter(category) || category.equals("Nd");
+        if (actual != expected) {
+            printDiff(codePoint, "isLetterOrDigit", actual, expected);
+        }
+    }
+
+    private static void isSpaceCharTest(int codePoint, String category) {
+        boolean actual = Character.isSpaceChar(codePoint);
+        boolean expected = isSpaceChar(category);
+        if (actual != expected) {
+            printDiff(codePoint, "isSpaceChar", actual, expected);
+        }
+    }
+
+    private static void isWhitespaceTest(int codePoint, String category) {
+        boolean actual = Character.isWhitespace(codePoint);
+        boolean expected = isWhitespace(codePoint, category);
+        if (actual != expected) {
+            printDiff(codePoint, "isWhitespace", actual, expected);
+        }
+    }
+
+    private static void isTitleCaseTest(int codePoint, String category) {
+        boolean actual = Character.isTitleCase(codePoint);
+        boolean expected = category.equals("Lt");
+        if (actual != expected) {
+            printDiff(codePoint, "isTitleCase", actual, expected);
+        }
+    }
+
+    private static void isISOControlTest(int codePoint) {
+        boolean actual = Character.isISOControl(codePoint);
+        boolean expected = isISOControl(codePoint);
+        if (actual != expected) {
+            printDiff(codePoint, "isISOControl", actual, expected);
+        }
+    }
+
+    private static void isIdentifierIgnorableTest(int codePoint, String category) {
+        boolean actual = Character.isIdentifierIgnorable(codePoint);
+        boolean expected = isIdentifierIgnorable(codePoint, category);
+        if (actual != expected) {
+            printDiff(codePoint, "isIdentifierIgnorable", actual, expected);
+        }
+    }
+
+    private static void isJavaIdentifierStartTest(int codePoint, String category) {
+        boolean actual = Character.isJavaIdentifierStart(codePoint);
+        boolean expected = isJavaIdentifierStart(category);
+        if (actual != expected) {
+            printDiff(codePoint, "isJavaIdentifierStart", actual, expected);
+        }
+    }
+
+    private static void isJavaIdentifierPartTest(int codePoint, String category) {
+        boolean actual = Character.isJavaIdentifierPart(codePoint);
+        boolean expected = isJavaIdentifierPart(codePoint, category);
+        if (actual != expected) {
+            printDiff(codePoint, "isJavaIdentifierPart", actual, expected);
+        }
+    }
+
+    private static void isUnicodeIdentifierStartTest(int codePoint, String category) {
+        boolean actual = Character.isUnicodeIdentifierStart(codePoint);
+        boolean expected = isUnicodeIdentifierStart(category);
+        if (actual != expected) {
+            printDiff(codePoint, "isUnicodeIdentifierStart", actual, expected);
+        }
+    }
+
+    private static void isUnicodeIdentifierPartTest(int codePoint, String category) {
+        boolean actual = Character.isUnicodeIdentifierPart(codePoint);
+        boolean expected = isUnicodeIdentifierPart(codePoint, category);
+        if (actual != expected) {
+            printDiff(codePoint, "isUnicodeIdentifierPart", actual, expected);
+        }
+    }
+
+    private static boolean isLetter(String category) {
+        return category.equals("Lu") || category.equals("Ll")
+               || category.equals("Lt") || category.equals("Lm")
+               || category.equals("Lo");
+    }
+
+    private static boolean isSpaceChar(String category) {
+        return category.equals("Zs") || category.equals("Zl")
+               || category.equals("Zp");
+    }
+
+    private static boolean isWhitespace(int codePoint, String category) {
+        if (isSpaceChar(category) && codePoint != Integer.parseInt("00A0", 16)
+                && codePoint != Integer.parseInt("2007", 16)
+                && codePoint != Integer.parseInt("202F", 16)) {
+            return true;
+        } else {
+            if (codePoint == Integer.parseInt("0009", 16)
+                    || codePoint == Integer.parseInt("000A", 16)
+                    || codePoint == Integer.parseInt("000B", 16)
+                    || codePoint == Integer.parseInt("000C", 16)
+                    || codePoint == Integer.parseInt("000D", 16)
+                    || codePoint == Integer.parseInt("001C", 16)
+                    || codePoint == Integer.parseInt("001D", 16)
+                    || codePoint == Integer.parseInt("001E", 16)
+                    || codePoint == Integer.parseInt("001F", 16)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private static boolean isISOControl(int codePoint) {
+        return (codePoint > 0x00 && codePoint < 0x1f)
+               || (codePoint > 0x7f && codePoint < 0x9f)
+               || (codePoint == 0x00 || codePoint == 0x1f || codePoint == 0x7f || codePoint == 0x9f);
+    }
+
+    private static boolean isIdentifierIgnorable(int codePoint, String category) {
+        if (category.equals("Cf")) {
+            return true;
+        } else {
+            int a1 = Integer.parseInt("0000", 16);
+            int a2 = Integer.parseInt("0008", 16);
+            int b1 = Integer.parseInt("000E", 16);
+            int b2 = Integer.parseInt("001B", 16);
+            int c1 = Integer.parseInt("007F", 16);
+            int c2 = Integer.parseInt("009F", 16);
+
+            if ((codePoint > a1 && codePoint < a2) || (codePoint > b1 && codePoint < b2)
+                    || (codePoint > c1 && codePoint < c2) || (codePoint == a1 || codePoint == a2
+                    || codePoint == b1 || codePoint == b2 || codePoint == c1 || codePoint == c2)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private static boolean isJavaIdentifierStart(String category) {
+        return isLetter(category) || category.equals("Nl") || category.equals("Sc")
+               || category.equals("Pc");
+    }
+
+    private static boolean isJavaIdentifierPart(int codePoint, String category) {
+        return isLetter(category) || category.equals("Sc") || category.equals("Pc")
+               || category.equals("Nd") || category.equals("Nl")
+               || category.equals("Mc") || category.equals("Mn")
+               || isIdentifierIgnorable(codePoint, category);
+    }
+
+    private static boolean isUnicodeIdentifierStart(String category) {
+        return isLetter(category) || category.equals("Nl");
+    }
+
+    private static boolean isUnicodeIdentifierPart(int codePoint, String category) {
+        return isLetter(category) || category.equals("Pc") || category.equals("Nd")
+               || category.equals("Nl") || category.equals("Mc") || category.equals("Mn")
+               || isIdentifierIgnorable(codePoint, category);
+    }
+
+    private static void printDiff(int codePoint, String method, boolean actual, boolean expected) {
+        System.out.println("Not equal at codePoint <" + Integer.toHexString(codePoint)
+                + ">, method: " + method
+                + ", actual: " + actual + ", expected: " + expected);
+        diffs++;
+    }
+}
diff --git a/test/jdk/java/lang/Character/CheckBlocks.java b/test/jdk/java/lang/Character/CheckBlocks.java
deleted file mode 100644
index 6e1b04a..0000000
--- a/test/jdk/java/lang/Character/CheckBlocks.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/**
- * @test
- * @bug 4830803 4886934 6565620 6959267 7070436 7198195 8032446 8072600
- * @summary  Check that the UnicodeBlock forName() method works as expected and block ranges are correct for all Unicode characters.
- * @run main CheckBlocks
- * @author John O'Conner
- */
-
-import java.io.*;
-import java.util.*;
-import java.lang.Character.UnicodeBlock;
-
-
-public class CheckBlocks {
-
-    static boolean err = false;
-    static Class<?> character;
-
-    public static void main(String[] args) throws Exception {
-        generateBlockList();
-
-        try {
-            character = Class.forName("java.lang.Character$UnicodeBlock");
-        } catch (ClassNotFoundException e) {
-            throw new RuntimeException("Class.forName(\"Character\") failed.");
-        }
-
-        for (Block blk : blocks) {
-            test4830803_1(blk);
-            test4830803_2();
-            test4886934(blk);
-        }
-
-        if (err) {
-            throw new RuntimeException("Failed");
-        } else {
-            System.out.println("Passed");
-        }
-    }
-
-    /**
-     * Check that the UnicodeBlock forName() method works as expected.
-     */
-    private static void test4830803_1(Block blk) throws Exception {
-
-        /*
-         * Try 3 forms of block name in the forName() method. Each form should
-         * produce the same expected block.
-         */
-        String blkName = blk.getName();
-
-        // For backward compatibility
-        if (blkName.equals("COMBINING_DIACRITICAL_MARKS_FOR_SYMBOLS")) {
-            blkName = "COMBINING_MARKS_FOR_SYMBOLS";
-            System.out.println("*** COMBINING_DIACRITICAL_MARKS_FOR_SYMBOLS is replaced with COMBINING_MARKS_FOR_SYMBOLS for backward compatibility.");
-        } else if (blkName.equals("GREEK_AND_COPTIC")) {
-            blkName = "GREEK";
-            System.out.println("*** GREEK_AND_COPTIC is replaced with GREEK for backward compatibility.");
-        } else if (blkName.equals("CYRILLIC_SUPPLEMENT")) {
-            blkName = "CYRILLIC_SUPPLEMENTARY";
-            System.out.println("*** CYRILLIC_SUPPLEMENT is replaced with CYRILLIC_SUPPLEMENTARY for backward compatibility.");
-        }
-
-        String expectedBlock = null;
-        try {
-            expectedBlock = character.getField(blkName).getName();
-        } catch (NoSuchFieldException | SecurityException e) {
-            System.err.println("Error: " + blkName + " was not found.");
-            err = true;
-            return;
-        }
-
-        String canonicalBlockName = blk.getOriginalName();
-        String idBlockName = expectedBlock;
-        String regexBlockName = toRegExString(canonicalBlockName);
-
-        if (regexBlockName == null) {
-            System.err.println("Error: Block name which was processed with regex was null.");
-            err = true;
-            return;
-        }
-
-        if (!expectedBlock.equals(UnicodeBlock.forName(canonicalBlockName).toString())) {
-            System.err.println("Error #1: UnicodeBlock.forName(\"" +
-                canonicalBlockName + "\") returned wrong value.\n\tGot: " +
-                UnicodeBlock.forName(canonicalBlockName) +
-                "\n\tExpected: " + expectedBlock);
-            err = true;
-        }
-
-        if (!expectedBlock.equals(UnicodeBlock.forName(idBlockName).toString())) {
-            System.err.println("Error #2: UnicodeBlock.forName(\"" +
-                idBlockName + "\") returned wrong value.\n\tGot: " +
-                UnicodeBlock.forName(idBlockName) +
-                "\n\tExpected: " + expectedBlock);
-            err = true;
-        }
-
-        if (!expectedBlock.equals(UnicodeBlock.forName(regexBlockName).toString())) {
-            System.err.println("Error #3: UnicodeBlock.forName(\"" +
-                regexBlockName + "\") returned wrong value.\n\tGot: " +
-                UnicodeBlock.forName(regexBlockName) +
-                "\n\tExpected: " + expectedBlock);
-            err = true;
-        }
-    }
-
-    /**
-     * now try a bad block name. This should produce an IAE.
-     */
-    private static void test4830803_2() {
-        boolean threwExpected = false;
-
-        try {
-            UnicodeBlock block = UnicodeBlock.forName("notdefined");
-        }
-        catch(IllegalArgumentException e) {
-            threwExpected = true;
-        }
-
-        if (threwExpected == false) {
-            System.err.println("Error: UnicodeBlock.forName(\"notdefined\") should throw IllegalArgumentException.");
-            err = true;
-        }
-    }
-
-    /**
-     * Convert the argument to a block name form used by the regex package.
-     * That is, remove all spaces.
-     */
-    private static String toRegExString(String str) {
-        String[] tokens = null;
-        StringBuilder retStr = new StringBuilder();
-        try {
-                   tokens = str.split(" ");
-        }
-        catch(java.util.regex.PatternSyntaxException e) {
-                   return null;
-        }
-        for(int x=0; x < tokens.length; ++x) {
-            retStr.append(tokens[x]);
-        }
-        return retStr.toString();
-    }
-
-    private static void test4886934(Block blk) {
-        String blkName = blk.getName();
-        String blkOrigName = blk.getOriginalName();
-        int ch =  blk.getBegin();
-        UnicodeBlock block = UnicodeBlock.of(ch);
-
-        if (block == null) {
-            System.err.println("Error: The block for " + blkName +
-                " is missing. Please check java.lang.Character.UnicodeBlock.");
-            err = true;
-            return;
-        }
-
-        // For backward compatibility
-        if (blkName.equals("COMBINING_DIACRITICAL_MARKS_FOR_SYMBOLS")) {
-            blkName = "COMBINING_MARKS_FOR_SYMBOLS";
-            System.out.println("*** COMBINING_DIACRITICAL_MARKS_FOR_SYMBOLS is replaced with COMBINING_MARKS_FOR_SYMBOLS for backward compatibility.");
-        } else if (blkName.equals("GREEK_AND_COPTIC")) {
-            blkName = "GREEK";
-            System.out.println("*** GREEK_AND_COPTIC is replaced with GREEK for backward compatibility.");
-        } else if (blkName.equals("CYRILLIC_SUPPLEMENT")) {
-            blkName = "CYRILLIC_SUPPLEMENTARY";
-            System.out.println("*** CYRILLIC_SUPPLEMENT is replaced with CYRILLIC_SUPPLEMENTARY for backward compatibility.");
-        }
-
-        String blockName = block.toString();
-        if (!blockName.equals(blkName)) {
-            System.err.println("Error: Begin-of-block character(0x" +
-                Integer.toHexString(ch).toUpperCase() +
-                ") should be in \"" + blkName + "\" block " +
-                "(Block name is \"" + blkOrigName + "\")" +
-                " but found in \"" + blockName + "\" block.");
-            err = true;
-        }
-
-        block = UnicodeBlock.of(++ch);
-        blockName = block.toString();
-        if (!blockName.equals(blkName)) {
-            System.err.println("Error: Character(0x" +
-                Integer.toHexString(ch).toUpperCase() +
-                ") should be in \"" + blkName + "\" block " +
-                "(Block name is \"" + blkOrigName + "\")" +
-                " but found in \"" + blockName + "\" block.");
-            err = true;
-        }
-
-        ch = blk.getEnd();
-        block = UnicodeBlock.of(ch);
-        blockName = block.toString();
-        if (!blockName.equals(blkName)) {
-            System.err.println("Error: End-of-block Character(0x" +
-                Integer.toHexString(ch).toUpperCase() +
-                ") should be in \"" + blkName + "\" block " +
-                "(Block name is \"" + blkOrigName + "\")" +
-                " but found in \"" + blockName + "\" block.");
-            err = true;
-        }
-    }
-
-    // List of all Unicode blocks, their start, and end codepoints.
-    public static HashSet<Block> blocks = new HashSet<>();
-
-    private static void generateBlockList() throws Exception {
-        BufferedReader f = new BufferedReader(new FileReader(new File(System.getProperty("test.src", "."), "Blocks.txt")));
-
-        String line;
-        while ((line = f.readLine()) != null) {
-            if (line.length() == 0 || line.charAt(0) == '#') {
-                continue;
-            }
-
-            int index1 = line.indexOf('.');
-            int begin = Integer.parseInt(line.substring(0, index1), 16);
-            int index2 = line.indexOf(';');
-            int end = Integer.parseInt(line.substring(index1+2, index2), 16);
-            String name = line.substring(index2+1).trim();
-
-            System.out.println("  Adding a Block(" +
-                Integer.toHexString(begin) + ", " + Integer.toHexString(end) +
-                ", " + name + ")");
-            blocks.add(new Block(begin, end, name));
-        }
-        f.close();
-    }
-}
-
-class Block {
-
-    public Block() {
-        blockBegin = 0;
-        blockEnd = 0;
-        blockName = null;
-    }
-
-    public Block(int begin, int end, String name) {
-        blockBegin = begin;
-        blockEnd = end;
-        blockName = name.replaceAll("[ -]", "_").toUpperCase(Locale.ENGLISH);
-        originalBlockName = name;
-    }
-
-    public int getBegin() {
-        return blockBegin;
-    }
-
-    public int getEnd() {
-        return blockEnd;
-    }
-
-    public String getName() {
-        return blockName;
-    }
-
-    public String getOriginalName() {
-        return originalBlockName;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == null) return false;
-        if (!(obj instanceof Block)) return false;
-
-        Block other = (Block)obj;
-        return other.blockBegin == blockBegin &&
-                other.blockEnd == blockEnd &&
-                other.blockName.equals(blockName) &&
-                other.originalBlockName.equals(originalBlockName);
-    }
-    int blockBegin, blockEnd;
-    String blockName, originalBlockName;
-}
diff --git a/test/jdk/java/lang/Character/TestISOControls.java b/test/jdk/java/lang/Character/TestISOControls.java
deleted file mode 100644
index 6339364..0000000
--- a/test/jdk/java/lang/Character/TestISOControls.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @summary  Check that ISO control ranges are valid.
- * @run main TestISOControls
- * @author John O'Conner
- */
-
-public class TestISOControls {
-
-
-  public static void main(String[] args) {
-
-    int[] test = { -1, 0, 0x0010, 0x001F, 0x0020, 0x007E, 0x007F, 0x0090,
-                   0x009F, 0x00A0 };
-    boolean[] expectedResult = { false, true, true, true, false, false, true,
-                                 true, true, false };
-
-    for (int x=0; x < test.length; ++x) {
-      if (Character.isISOControl(test[x]) != expectedResult[x]) {
-          System.out.println("Fail: " + test[x]);
-          throw new RuntimeException();
-      }
-
-    }
-    System.out.println("Passed");
-
-  }
-
-}
diff --git a/test/jdk/java/lang/Character/Blocks.txt b/test/jdk/java/lang/Character/UnicodeBlock/Blocks.txt
similarity index 100%
rename from test/jdk/java/lang/Character/Blocks.txt
rename to test/jdk/java/lang/Character/UnicodeBlock/Blocks.txt
diff --git a/test/jdk/java/lang/Character/UnicodeBlock/CheckBlocks.java b/test/jdk/java/lang/Character/UnicodeBlock/CheckBlocks.java
new file mode 100644
index 0000000..f747eb8
--- /dev/null
+++ b/test/jdk/java/lang/Character/UnicodeBlock/CheckBlocks.java
@@ -0,0 +1,346 @@
+/*
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4830803 4886934 6565620 6959267 7070436 7198195 8032446 8072600 8202771
+ * @summary  Check that the UnicodeBlock forName() method works as expected and block ranges are correct for all Unicode characters.
+ * @run main CheckBlocks
+ * @author John O'Conner
+ */
+
+import java.lang.Character.UnicodeBlock;
+import java.lang.reflect.Field;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.util.HashSet;
+import java.util.Locale;
+
+public class CheckBlocks {
+
+    static boolean err = false;
+    static Class<?> clazzUnicodeBlock;
+
+    public static void main(String[] args) throws Exception {
+        generateBlockList();
+
+        try {
+            clazzUnicodeBlock = Class.forName("java.lang.Character$UnicodeBlock");
+        } catch (ClassNotFoundException e) {
+            throw new RuntimeException("Class.forName(\"java.lang.Character$UnicodeBlock\") failed.");
+        }
+
+        for (Block blk : blocks) {
+            test4830803_1(blk);
+            test4830803_2();
+            test4886934(blk);
+        }
+
+        test8202771();
+
+        if (err) {
+            throw new RuntimeException("Failed");
+        } else {
+            System.out.println("Passed");
+        }
+    }
+
+    /**
+     * Check that the UnicodeBlock forName() method works as expected.
+     */
+    private static void test4830803_1(Block blk) throws Exception {
+
+        /*
+         * Try 3 forms of block name in the forName() method. Each form should
+         * produce the same expected block.
+         */
+        String blkName = blk.getName();
+
+        // For backward compatibility
+        switch (blkName) {
+            case "COMBINING_DIACRITICAL_MARKS_FOR_SYMBOLS":
+                blkName = "COMBINING_MARKS_FOR_SYMBOLS";
+                System.out.println("*** COMBINING_DIACRITICAL_MARKS_FOR_SYMBOLS"
+                        + " is replaced with COMBINING_MARKS_FOR_SYMBOLS"
+                        + " for backward compatibility.");
+                break;
+            case "GREEK_AND_COPTIC":
+                blkName = "GREEK";
+                System.out.println("*** GREEK_AND_COPTIC is replaced with GREEK"
+                        + " for backward compatibility.");
+                break;
+            case "CYRILLIC_SUPPLEMENT":
+                blkName = "CYRILLIC_SUPPLEMENTARY";
+                System.out.println("*** CYRILLIC_SUPPLEMENT is replaced with"
+                        + " CYRILLIC_SUPPLEMENTARY for backward compatibility.");
+                break;
+            default:
+                break;
+        }
+
+        String expectedBlock = null;
+        try {
+            expectedBlock = clazzUnicodeBlock.getField(blkName).getName();
+        } catch (NoSuchFieldException | SecurityException e) {
+            System.err.println("Error: " + blkName + " was not found.");
+            err = true;
+            return;
+        }
+
+        String canonicalBlockName = blk.getOriginalName();
+        String idBlockName = expectedBlock;
+        String regexBlockName = toRegExString(canonicalBlockName);
+
+        if (regexBlockName == null) {
+            System.err.println("Error: Block name which was processed with regex was null.");
+            err = true;
+            return;
+        }
+
+        if (!expectedBlock.equals(UnicodeBlock.forName(canonicalBlockName).toString())) {
+            System.err.println("Error #1: UnicodeBlock.forName(\"" +
+                    canonicalBlockName + "\") returned wrong value.\n\tGot: " +
+                    UnicodeBlock.forName(canonicalBlockName) +
+                    "\n\tExpected: " + expectedBlock);
+            err = true;
+        }
+
+        if (!expectedBlock.equals(UnicodeBlock.forName(idBlockName).toString())) {
+            System.err.println("Error #2: UnicodeBlock.forName(\"" +
+                    idBlockName + "\") returned wrong value.\n\tGot: " +
+                    UnicodeBlock.forName(idBlockName) +
+                    "\n\tExpected: " + expectedBlock);
+            err = true;
+        }
+
+        if (!expectedBlock.equals(UnicodeBlock.forName(regexBlockName).toString())) {
+            System.err.println("Error #3: UnicodeBlock.forName(\"" +
+                    regexBlockName + "\") returned wrong value.\n\tGot: " +
+                    UnicodeBlock.forName(regexBlockName) +
+                    "\n\tExpected: " + expectedBlock);
+            err = true;
+        }
+    }
+
+    /**
+     * now try a bad block name. This should produce an IAE.
+     */
+    private static void test4830803_2() {
+        boolean threwExpected = false;
+
+        try {
+            UnicodeBlock block = UnicodeBlock.forName("notdefined");
+        }
+        catch(IllegalArgumentException e) {
+            threwExpected = true;
+        }
+
+        if (threwExpected == false) {
+            System.err.println("Error: UnicodeBlock.forName(\"notdefined\") should throw IllegalArgumentException.");
+            err = true;
+        }
+    }
+
+    /**
+     * Convert the argument to a block name form used by the regex package.
+     * That is, remove all spaces.
+     */
+    private static String toRegExString(String str) {
+        String[] tokens = null;
+        StringBuilder retStr = new StringBuilder();
+        try {
+            tokens = str.split(" ");
+        }
+        catch(java.util.regex.PatternSyntaxException e) {
+            return null;
+        }
+        for(int x=0; x < tokens.length; ++x) {
+            retStr.append(tokens[x]);
+        }
+        return retStr.toString();
+    }
+
+    private static void test4886934(Block blk) {
+        String blkName = blk.getName();
+        String blkOrigName = blk.getOriginalName();
+        UnicodeBlock block;
+        String blockName;
+
+        // For backward compatibility
+        switch (blkName) {
+            case "COMBINING_DIACRITICAL_MARKS_FOR_SYMBOLS":
+                blkName = "COMBINING_MARKS_FOR_SYMBOLS";
+                System.out.println("*** COMBINING_DIACRITICAL_MARKS_FOR_SYMBOLS"
+                        + " is replaced with COMBINING_MARKS_FOR_SYMBOLS"
+                        + " for backward compatibility.");
+                break;
+            case "GREEK_AND_COPTIC":
+                blkName = "GREEK";
+                System.out.println("*** GREEK_AND_COPTIC is replaced with GREEK"
+                        + " for backward compatibility.");
+                break;
+            case "CYRILLIC_SUPPLEMENT":
+                blkName = "CYRILLIC_SUPPLEMENTARY";
+                System.out.println("*** CYRILLIC_SUPPLEMENT is replaced with"
+                        + " CYRILLIC_SUPPLEMENTARY for backward compatibility.");
+                break;
+            default:
+                break;
+        }
+
+        for (int ch = blk.getBegin(); ch <= blk.getEnd(); ch++) {
+            block = UnicodeBlock.of(ch);
+            if (block == null) {
+                System.err.println("Error: The block for " + blkName
+                        + " is missing. Please check java.lang.Character.UnicodeBlock.");
+                err = true;
+                break;
+            }
+            blockName = block.toString();
+            if (!blockName.equals(blkName)) {
+                System.err.println("Error: Character(0x"
+                        + Integer.toHexString(ch).toUpperCase()
+                        + ") should be in \"" + blkName + "\" block "
+                        + "(Block name is \"" + blkOrigName + "\")"
+                        + " but found in \"" + blockName + "\" block.");
+                err = true;
+            }
+        }
+    }
+
+    /**
+     * Check if every Field of Character.UnicodeBlock is a valid Unicode Block.
+     */
+    private static void test8202771() {
+        Field[] fields = clazzUnicodeBlock.getFields();
+
+        for (Field f : fields) {
+            // Handle Deprecated field "SURROGATES_AREA".
+            if (f.getAnnotation(Deprecated.class) != null) {
+                continue;
+            }
+
+            String blkName = f.getName();
+            switch (blkName) {
+                case "COMBINING_MARKS_FOR_SYMBOLS":
+                    validateBlock("COMBINING_DIACRITICAL_MARKS_FOR_SYMBOLS");
+                    break;
+                case "GREEK":
+                    validateBlock("GREEK_AND_COPTIC");
+                    break;
+                case "CYRILLIC_SUPPLEMENTARY":
+                    validateBlock("CYRILLIC_SUPPLEMENT");
+                    break;
+                default:
+                    validateBlock(blkName);
+                    break;
+            }
+        }
+    }
+
+    private static void validateBlock(String blkName) {
+        for (Block block : blocks) {
+            String blockName = block.getName();
+            if (blockName.equals(blkName)) {
+                return;
+            }
+        }
+        err = true;
+        System.err.println(blkName + " is not a valid Unicode Block.");
+    }
+
+    // List of all Unicode blocks, their start, and end codepoints.
+    public static HashSet<Block> blocks = new HashSet<>();
+
+    private static void generateBlockList() throws Exception {
+        File blockData = new File(System.getProperty("test.src", "."),
+                "Blocks.txt");
+        try (BufferedReader f = new BufferedReader(new FileReader(blockData))) {
+            String line;
+            while ((line = f.readLine()) != null) {
+                if (line.length() == 0 || line.charAt(0) == '#') {
+                    continue;
+                }
+
+                int index1 = line.indexOf('.');
+                int begin = Integer.parseInt(line.substring(0, index1), 16);
+                int index2 = line.indexOf(';');
+                int end = Integer.parseInt(line.substring(index1 + 2, index2), 16);
+                String name = line.substring(index2 + 1).trim();
+
+                System.out.println("  Adding a Block(" + Integer.toHexString(begin) + ", " + Integer.toHexString(end)
+                        + ", " + name + ")");
+                blocks.add(new Block(begin, end, name));
+            }
+        }
+    }
+}
+
+class Block {
+
+    public Block() {
+        blockBegin = 0;
+        blockEnd = 0;
+        blockName = null;
+    }
+
+    public Block(int begin, int end, String name) {
+        blockBegin = begin;
+        blockEnd = end;
+        blockName = name.replaceAll("[ -]", "_").toUpperCase(Locale.ENGLISH);
+        originalBlockName = name;
+    }
+
+    public int getBegin() {
+        return blockBegin;
+    }
+
+    public int getEnd() {
+        return blockEnd;
+    }
+
+    public String getName() {
+        return blockName;
+    }
+
+    public String getOriginalName() {
+        return originalBlockName;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == null) return false;
+        if (!(obj instanceof Block)) return false;
+
+        Block other = (Block)obj;
+        return other.blockBegin == blockBegin &&
+                other.blockEnd == blockEnd &&
+                other.blockName.equals(blockName) &&
+                other.originalBlockName.equals(originalBlockName);
+    }
+    int blockBegin, blockEnd;
+    String blockName, originalBlockName;
+}