8195981: Move some tests to OpenJDK for jdk_lang test group
authoramlu
Mon, 05 Feb 2018 11:12:09 +0800
changeset 48742 364944ba4e2f
parent 48741 d682d3da7923
child 48743 ba52fa7bbf14
8195981: Move some tests to OpenJDK for jdk_lang test group Reviewed-by: alanb, mchung
test/jdk/java/lang/Character/Bug4404588.java
test/jdk/java/lang/Character/Supplementary.java
test/jdk/java/lang/Character/TestISOControls.java
test/jdk/java/lang/Character/TestNegativeCodepoint.java
test/jdk/java/lang/Character/TestUndefinedDirectionality.java
test/jdk/java/lang/Character/TestUndefinedIdentifierStartPart.java
test/jdk/java/lang/Character/TestUndefinedIgnorable.java
test/jdk/java/lang/Character/TestUndefinedMirrored.java
test/jdk/java/lang/Character/TestUndefinedNumeric.java
test/jdk/java/lang/Character/TestUndefinedTitleCase.java
test/jdk/java/lang/Character/TestWhiteSpace.java
test/jdk/java/lang/Package/A.java
test/jdk/java/lang/Package/IsCompatibleWith.java
test/jdk/java/lang/Package/IsCompatibleWithDriver.java
test/jdk/java/lang/Package/test.mf
test/jdk/java/lang/Runtime/Resources.java
test/jdk/java/lang/Runtime/shutdown/Basic.java
test/jdk/java/lang/SecurityManager/CheckAccessClassInPackagePermissions.java
test/jdk/java/lang/System/ClearProperty.java
test/jdk/java/lang/System/NonAnsiFileEncodingTest.java
test/jdk/java/lang/System/SetProperties.java
test/jdk/jdk/internal/loader/InterruptedClassLoad.java
test/jdk/jdk/internal/math/ToString.java
test/jdk/vm/gc/ArraySize.java
test/jdk/vm/gc/InfiniteList.java
test/jdk/vm/jit/BadLogicCode.java
test/jdk/vm/jit/ExceptionInInit.java
test/jdk/vm/jit/JITClassInit.java
test/jdk/vm/runtime/ExplicitArithmeticCheck.java
test/jdk/vm/runtime/MonitorCacheMaybeExpand_DeadLock.java
test/jdk/vm/runtime/ReflectStackOverflow.java
test/jdk/vm/runtime/ShiftTest.java
test/jdk/vm/runtime/WideStrictInline.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/Character/Bug4404588.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,73 @@
+/*
+ * 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 The characters FFFE and FFFF should not be in a UnicodeBlock. They
+ *          should be in a null block.
+ * @bug 4404588
+ * @author John O'Conner
+ */
+
+ public class Bug4404588 {
+
+    public Bug4404588() {
+        // do nothing
+    }
+
+    public static void main(String[] args) {
+        Bug4404588 test = new Bug4404588();
+        test.run();
+    }
+
+    /**
+     * Test the correct data against what Character reports.
+     */
+    void run() {
+        Character ch;
+        Character.UnicodeBlock block;
+
+        for(int x=0; x < charData.length; x++) {
+            ch = (Character)charData[x][0];
+            block = (Character.UnicodeBlock)charData[x][1];
+
+            if (Character.UnicodeBlock.of(ch.charValue()) != block) {
+                System.err.println("Error: block = " + block);
+                System.err.println("Character.UnicodeBlock.of(" +
+                    Integer.toHexString(ch.charValue()) +") = " +
+                    Character.UnicodeBlock.of(ch.charValue()));
+                throw new RuntimeException("Blocks aren't equal.");
+            }
+        }
+        System.out.println("Passed.");
+    }
+
+    /**
+     * Contains the character data to test. The first object is the character.
+     * The next object is the UnicodeBlock to which it should belong.
+     */
+    Object[][] charData = {
+        { new Character('\uFFFE'), Character.UnicodeBlock.SPECIALS },
+        { new Character('\uFFFF'), Character.UnicodeBlock.SPECIALS },
+    };
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/Character/Supplementary.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,856 @@
+/*
+ * 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 4533872 4985214 4985217 5017268 5017280
+ * @summary Unit tests for supplementary character support (JSR-204)
+ * @compile Supplementary.java
+ * @run main/timeout=600 Supplementary
+ */
+
+public class Supplementary {
+    private static final char MIN_HIGH = '\uD800';
+    private static final char MAX_HIGH = '\uDBFF';
+    private static final char MIN_LOW = MAX_HIGH + 1;
+    private static final char MAX_LOW = '\uDFFF';
+    private static final int MIN_CODE_POINT = 0x000000;
+    private static final int MIN_SUPPLEMENTARY = 0x010000;
+    private static final int MAX_SUPPLEMENTARY = 0x10ffff;
+
+    public static void main(String[] args) {
+        // Do not change the order of test method calls since there
+        // are some interdependencies.
+
+        testConstants();
+
+        test00();
+
+        // Store all Unicode code points, except for surrogate code
+        // points, in cu[] through the loops below. Then, use the data
+        // for code point/code unit conversion and other tests later.
+        char[] cu = new char[(MAX_SUPPLEMENTARY+1) * 2];
+        int length = test01(cu);
+
+        String str = new String(cu, 0, length);
+        cu = null;
+        test02(str);
+        test03(str.toCharArray());
+        test04(str);
+        test05(str);
+
+        // Test unpaired surrogates
+        testUnpaired();
+
+        // Test exceptions
+        testExceptions00();
+        testExceptions01(str);
+        testExceptions02(str.toCharArray());
+    }
+
+    static void testConstants() {
+        if (Character.MIN_HIGH_SURROGATE != MIN_HIGH) {
+            constantError("MIN_HIGH_SURROGATE", Character.MIN_HIGH_SURROGATE, MIN_HIGH);
+        }
+        if (Character.MAX_HIGH_SURROGATE != MAX_HIGH) {
+            constantError("MAX_HIGH_SURROGATE", Character.MAX_HIGH_SURROGATE, MAX_HIGH);
+        }
+        if (Character.MIN_LOW_SURROGATE != MIN_LOW) {
+            constantError("MIN_LOW_SURROGATE", Character.MIN_LOW_SURROGATE, MIN_LOW);
+        }
+        if (Character.MAX_LOW_SURROGATE != MAX_LOW) {
+            constantError("MAX_LOW_SURROGATE", Character.MAX_LOW_SURROGATE, MAX_LOW);
+        }
+        if (Character.MIN_SURROGATE != MIN_HIGH) {
+            constantError("MIN_SURROGATE", Character.MIN_SURROGATE, MIN_HIGH);
+        }
+        if (Character.MAX_SURROGATE != MAX_LOW) {
+            constantError("MAX_SURROGATE", Character.MAX_SURROGATE, MAX_LOW);
+        }
+        if (Character.MIN_SUPPLEMENTARY_CODE_POINT != MIN_SUPPLEMENTARY) {
+            constantError("MIN_SUPPLEMENTARY_CODE_POINT",
+                          Character.MIN_SUPPLEMENTARY_CODE_POINT, MIN_SUPPLEMENTARY);
+        }
+        if (Character.MIN_CODE_POINT != MIN_CODE_POINT) {
+            constantError("MIN_CODE_POINT", Character.MIN_CODE_POINT, MIN_CODE_POINT);
+        }
+        if (Character.MAX_CODE_POINT != MAX_SUPPLEMENTARY) {
+            constantError("MAX_CODE_POINT", Character.MAX_CODE_POINT, MAX_SUPPLEMENTARY);
+        }
+    }
+
+    static void constantError(String name, int value, int expectedValue) {
+        throw new RuntimeException("Character." + name + " has a wrong value: got "
+                                   + toHexString(value)
+                                   + ", expected " + toHexString(expectedValue));
+    }
+
+    /*
+     * Test isValidCodePoint(int)
+     *      isSupplementaryCodePoint(int)
+     *      charCount(int)
+     */
+    static void test00() {
+        for (int cp = -MAX_SUPPLEMENTARY; cp <= MAX_SUPPLEMENTARY*2; cp++) {
+            boolean isValid = cp >= 0 && cp <= MAX_SUPPLEMENTARY;
+            if (Character.isValidCodePoint(cp) != isValid) {
+                throw new RuntimeException("isValidCodePoint failed with "
+                                           + toHexString(cp));
+            }
+            boolean isSupplementary = cp >= MIN_SUPPLEMENTARY && cp <= MAX_SUPPLEMENTARY;
+            if (Character.isSupplementaryCodePoint(cp) != isSupplementary) {
+                throw new RuntimeException("isSupplementaryCodePoint failed with "
+                                           + toHexString(cp));
+            }
+            int len = Character.charCount(cp);
+            if (isValid) {
+                if ((isSupplementary && len != 2)
+                    || (!isSupplementary && len != 1)) {
+                    throw new RuntimeException("wrong character length "+len+" for "
+                                               + toHexString(cp));
+                }
+            } else if (len != 1 && len != 2) {
+                throw new RuntimeException("wrong character length "+len+" for "
+                                           + toHexString(cp));
+            }
+        }
+    }
+
+    /**
+     * Test toChar(int)
+     *      toChar(int, char[], int)
+     *      isHighSurrogate(char)
+     *      isLowSurrogate(char)
+     *      isSurrogatePair(int, int)
+     *
+     * While testing those methods, this method generates all Unicode
+     * code points (except for surrogate code points) and store them
+     * in cu.
+     *
+     * @return the number of code units generated in cu
+     */
+    static int test01(char[] cu) {
+        int index = 0;
+        // Test toChar(int)
+        //      toChar(int, char[], int)
+        //      isHighSurrogate(char)
+        //      isLowSurrogate(char)
+        // with BMP code points
+        for (int i = 0; i <= Character.MAX_VALUE; i++) {
+            char[] u = Character.toChars(i);
+            if (u.length != 1 || u[0] != i) {
+                throw new RuntimeException("wrong toChars(int) result for BMP: "
+                                           + toHexString("u", u));
+            }
+            int n = Character.toChars(i, cu, index);
+            if (n != 1 || cu[index] != i) {
+                throw new RuntimeException("wrong toChars(int, char[], int) result for BMP:"
+                                           + " len=" + n
+                                           + ", cu["+index+"]="+toHexString(cu[index]));
+            }
+            boolean isHigh = i >= MIN_HIGH && i <= MAX_HIGH;
+            if (Character.isHighSurrogate((char) i) != isHigh) {
+                throw new RuntimeException("wrong high-surrogate test for "
+                                           + toHexString(i));
+            }
+            boolean isLow = i >= MIN_LOW && i <= MAX_LOW;
+            if (Character.isLowSurrogate((char)i) != isLow) {
+                throw new RuntimeException("wrong low-surrogate test for "
+                                           + toHexString(i));
+            }
+            if (!isHigh && !isLow) {
+                index++;
+            }
+        }
+
+        // Test isSurrogatePair with all surrogate pairs
+        // Test toChars(int)
+        //      toChars(int, char[], int)
+        // with all supplementary characters
+        int supplementary = MIN_SUPPLEMENTARY;
+        for (int i = Character.MAX_VALUE/2; i <= Character.MAX_VALUE; i++) {
+            char hi = (char) i;
+            boolean isHigh = Character.isHighSurrogate(hi);
+
+            for (int j = Character.MAX_VALUE/2; j <= Character.MAX_VALUE; j++) {
+                char lo = (char) j;
+                boolean isLow = Character.isLowSurrogate(lo);
+                boolean isSurrogatePair = isHigh && isLow;
+                if (Character.isSurrogatePair(hi, lo) != isSurrogatePair) {
+                    throw new RuntimeException("wrong surrogate pair test for hi="
+                                               + toHexString(hi)
+                                               + ", lo="+toHexString(lo));
+                }
+                if (isSurrogatePair) {
+                    int cp = Character.toCodePoint(hi, lo);
+                    if (cp != supplementary) {
+                        throw new RuntimeException("wrong code point: got "
+                                                   + toHexString(cp)
+                                                   + ", expected="
+                                                   + toHexString(supplementary));
+                    }
+                    char[] u = Character.toChars(cp);
+                    if (u.length != 2 || u[0] != hi || u[1] != lo) {
+                        throw new RuntimeException("wrong toChars(int) result for supplementary: "+
+                                                   toHexString("u", u));
+                    }
+                    int n = Character.toChars(cp, cu, index);
+                    if (n != 2 || cu[index] != hi || cu[index+1] != lo) {
+                        throw new RuntimeException("wrong toChars(int, char[], int) result "
+                                           + "for supplementary: len=" + n
+                                           + ", cu["+index+"]=" + toHexString(cu[index])
+                                           + ", cu["+(index+1)+"]=" + toHexString(cu[index+1]));
+                    }
+                    index += n;
+                    supplementary++;
+                }
+            }
+        }
+        if (supplementary != MAX_SUPPLEMENTARY + 1) {
+            throw new RuntimeException("wrong supplementary count (supplementary="
+                                       + toHexString(supplementary)+")");
+        }
+
+        int nCodeUnits = Character.MAX_VALUE + 1 - (MAX_LOW - MIN_HIGH + 1)
+                         + ((MAX_SUPPLEMENTARY - MIN_SUPPLEMENTARY + 1) * 2);
+        if (index != nCodeUnits) {
+            throw new RuntimeException("wrong number of code units: " + index
+                                       + ", expected " + nCodeUnits);
+        }
+        return index;
+    }
+
+    /**
+     * Test codePointAt(CharSequence, int)
+     *      codePointBefore(CharSequence, int)
+     */
+    static void test02(CharSequence cs) {
+        int cp = 0;
+        int ch;
+        for (int i = 0; i < cs.length(); i += Character.charCount(ch)) {
+            ch = Character.codePointAt(cs, i);
+            if (ch != cp) {
+                throw new RuntimeException("wrong codePointAt(CharSequence, "+i+") value: got "
+                                           + toHexString(ch)
+                                           + ", expected "+toHexString(cp));
+            }
+            cp++;
+            // Skip surrogates
+            if (cp == MIN_HIGH) {
+                cp = MAX_LOW + 1;
+            }
+        }
+
+        cp--;
+        for (int i = cs.length(); i > 0; i -= Character.charCount(ch)) {
+            ch = Character.codePointBefore(cs, i);
+            if (ch != cp) {
+                throw new RuntimeException("codePointBefore(CharSequence, "+i+") returned "
+                                           + toHexString(ch)
+                                           + ", expected " + toHexString(cp));
+            }
+            cp--;
+            // Skip surrogates
+            if (cp == MAX_LOW) {
+                cp = MIN_HIGH - 1;
+            }
+        }
+    }
+
+    /**
+     * Test codePointAt(char[], int)
+     *      codePointAt(char[], int, int)
+     *      codePointBefore(char[], int)
+     *      codePointBefore(char[], int, int)
+     */
+    static void test03(char[] a) {
+        int cp = 0;
+        int ch;
+        for (int i = 0; i < a.length; i += Character.charCount(ch)) {
+            ch = Character.codePointAt(a, i);
+            if (ch != cp) {
+                throw new RuntimeException("codePointAt(char[], "+i+") returned "
+                                           + toHexString(ch)
+                                           + ", expected "+toHexString(cp));
+            }
+            int x = Character.codePointAt(a, i, i+1);
+            if (x != a[i]) {
+                throw new RuntimeException(String.format(
+                                 "codePointAt(char[], %d, %d) returned 0x%04x, expected 0x%04x\n",
+                                 i, i+1, x, (int)a[i]));
+            }
+            cp++;
+            // Skip surrogates
+            if (cp == MIN_HIGH) {
+                cp = MAX_LOW + 1;
+            }
+        }
+
+        cp--;
+        for (int i = a.length; i > 0; i -= Character.charCount(ch)) {
+            ch = Character.codePointBefore(a, i);
+            if (ch != cp) {
+                throw new RuntimeException("codePointBefore(char[], "+i+") returned "
+                                           + toHexString(ch)
+                                           + ", expected " + toHexString(cp));
+            }
+            int x = Character.codePointBefore(a, i, i-1);
+            if (x != a[i-1]) {
+                throw new RuntimeException(String.format(
+                                 "codePointAt(char[], %d, %d) returned 0x%04x, expected 0x%04x\n",
+                                 i, i-1, x, (int)a[i-1]));
+            }
+            cp--;
+            // Skip surrogates
+            if (cp == MAX_LOW) {
+                cp = MIN_HIGH - 1;
+            }
+        }
+    }
+
+    /**
+     * Test codePointCount(CharSequence, int, int)
+     *      codePointCount(char[], int, int, int, int)
+     */
+    static void test04(String str) {
+        int length = str.length();
+        char[] a = str.toCharArray();
+
+        for (int i = 0; i <= length; i += 99, length -= 29999) {
+            int n = Character.codePointCount(str, i, length);
+            int m = codePointCount(str.substring(i, length));
+            checkCodePointCount(str, n, m);
+            n = Character.codePointCount(a, i, length - i);
+            checkCodePointCount(a, n, m);
+        }
+
+        // test special cases
+        length = str.length();
+        int n = Character.codePointCount(str, 0, 0);
+        checkCodePointCount(str, n, 0);
+        n = Character.codePointCount(str, length, length);
+        checkCodePointCount(str, n, 0);
+        n = Character.codePointCount(a, 0, 0);
+        checkCodePointCount(a, n, 0);
+        n = Character.codePointCount(a, length, 0);
+        checkCodePointCount(a, n, 0);
+    }
+
+    // This method assumes that Character.codePointAt() and
+    // Character.charCount() work correctly.
+    private static int codePointCount(CharSequence seq) {
+        int n = 0, len;
+        for (int i = 0; i < seq.length(); i += len) {
+            int codepoint = Character.codePointAt(seq, i);
+            n++;
+            len = Character.charCount(codepoint);
+        }
+        return n;
+    }
+
+    private static void checkCodePointCount(Object data, int n, int expected) {
+        String type = getType(data);
+        if (n != expected) {
+            throw new RuntimeException("codePointCount(" + type + "...) returned " + n
+                                       + ", expected " + expected);
+        }
+    }
+
+    /**
+     * Test offsetByCodePoints(CharSequence, int, int)
+     *      offsetByCodePoints(char[], int, int, int, int)
+     *
+     * This test case assumes that Character.codePointCount()s work
+     * correctly.
+     */
+    static void test05(String str) {
+        int length = str.length();
+        char[] a = str.toCharArray();
+
+        for (int i = 0; i <= length; i += 99, length -= 29999) {
+            int nCodePoints = Character.codePointCount(a, i, length - i);
+            int index;
+
+            // offsetByCodePoints(CharSequence, int, int)
+
+            int expectedHighIndex = length;
+            // For forward CharSequence scan, we need to adjust the
+            // expected index in case the last char in the text range
+            // is a high surrogate and forms a valid supplementary
+            // code point with the next char.
+            if (length < a.length) {
+                int cp = Character.codePointAt(a, length - 1);
+                if (Character.isSupplementaryCodePoint(cp)) {
+                    expectedHighIndex++;
+                }
+            }
+            index = Character.offsetByCodePoints(str, i, nCodePoints);
+            checkNewIndex(str, nCodePoints, index, expectedHighIndex);
+            int expectedLowIndex = i;
+            if (i > 0) {
+                int cp = Character.codePointBefore(a, i + 1);
+                if (Character.isSupplementaryCodePoint(cp)) {
+                    expectedLowIndex--;
+                }
+            }
+            index = Character.offsetByCodePoints(str, length, -nCodePoints);
+            checkNewIndex(str, -nCodePoints, index, expectedLowIndex);
+
+            // offsetByCodePoints(char[], int, int, int, int)
+
+            int start = Math.max(0, i-1);
+            int limit = Math.min(a.length, length+1);
+            index = Character.offsetByCodePoints(a, start, limit - start,
+                                                 i, nCodePoints);
+            checkNewIndex(a, nCodePoints, index, expectedHighIndex);
+            if (length != expectedHighIndex) {
+                index = Character.offsetByCodePoints(a, start, length - start,
+                                                     i, nCodePoints);
+                checkNewIndex(a, nCodePoints, index, length);
+            }
+            index = Character.offsetByCodePoints(a, start, limit - start,
+                                                 length, -nCodePoints);
+            checkNewIndex(a, -nCodePoints, index, expectedLowIndex);
+            if (i != expectedLowIndex) {
+                index = Character.offsetByCodePoints(a, i, limit - i,
+                                                     length, -nCodePoints);
+                checkNewIndex(a, -nCodePoints, index, i);
+            }
+        }
+
+        // test special cases for 0-length text ranges.
+        length = str.length();
+        int index = Character.offsetByCodePoints(str, 0, 0);
+        checkNewIndex(str, 0, index, 0);
+        index = Character.offsetByCodePoints(str, length, 0);
+        checkNewIndex(str, 0, index, length);
+        index = Character.offsetByCodePoints(a, 0, 0, 0, 0);
+        checkNewIndex(a, 0, index, 0);
+        index = Character.offsetByCodePoints(a, 0, length, 0, 0);
+        checkNewIndex(a, 0, index, 0);
+        index = Character.offsetByCodePoints(a, 0, length, length, 0);
+        checkNewIndex(a, 0, index, length);
+        index = Character.offsetByCodePoints(a, length, 0, length, 0);
+        checkNewIndex(a, 0, index, length);
+    }
+
+    private static void checkNewIndex(Object data, int offset, int result, int expected) {
+        String type = getType(data);
+        String offsetType = (offset > 0) ? "positive" : (offset < 0) ? "negative" : "0";
+        if (result != expected) {
+            throw new RuntimeException("offsetByCodePoints(" + type + ", ...) ["
+                                       + offsetType + " offset]"
+                                       + " returned " + result
+                                       + ", expected " + expected);
+        }
+    }
+
+    // Test codePointAt(CharSequence, int)
+    //      codePointBefore(CharSequence, int)
+    //      codePointAt(char[], int)
+    //      codePointBefore(char[], int)
+    //      toChar(int)
+    //      toChar(int, char[], int)
+    // with unpaired surrogates
+    static void testUnpaired() {
+        testCodePoint("\uD800", new int[] { 0xD800 });
+        testCodePoint("\uDC00", new int[] { 0xDC00 });
+        testCodePoint("a\uD800", new int[] { 'a', 0xD800 });
+        testCodePoint("a\uDC00", new int[] { 'a', 0xDC00 });
+        testCodePoint("\uD800a", new int[] { 0xD800, 'a' });
+        testCodePoint("\uDBFFa", new int[] { 0xDBFF, 'a' });
+        testCodePoint("a\uD800\uD801", new int[] { 'a', 0xD800, 0xD801 });
+        testCodePoint("a\uD800x\uDC00", new int[] { 'a', 0xD800, 'x', 0xDC00 });
+        testCodePoint("\uDC00\uD800", new int[] { 0xDC00, 0xD800 });
+        testCodePoint("\uD800\uDC00\uDC00", new int[] { 0x10000, 0xDC00 });
+        testCodePoint("\uD800\uD800\uDC00", new int[] { 0xD800, 0x10000 });
+        testCodePoint("\uD800\uD800\uD800\uD800\uDC00\uDC00\uDC00\uDC00",
+                      new int[] { 0xD800, 0xD800, 0xD800, 0x10000, 0xDC00, 0xDC00, 0xDC00});
+    }
+
+    static void testCodePoint(String str, int[] codepoints) {
+        int c;
+        // Test Character.codePointAt/Before(CharSequence, int)
+        int j = 0;
+        for (int i = 0; i < str.length(); i += Character.charCount(c)) {
+            c = Character.codePointAt(str, i);
+            if (c != codepoints[j++]) {
+                throw new RuntimeException("codePointAt(CharSequence, " + i + ") returned "
+                                           + toHexString(c)
+                                           + ", expected " + toHexString(codepoints[j-1]));
+            }
+        }
+        if (j != codepoints.length) {
+            throw new RuntimeException("j != codepoints.length after codePointAt(CharSequence, int)"
+                                       + " (j=" + j + ")"
+                                       + ", expected: " + codepoints.length);
+        }
+
+        j = codepoints.length;
+        for (int i = str.length(); i > 0 ; i -= Character.charCount(c)) {
+            c = Character.codePointBefore(str, i);
+            if (c != codepoints[--j]) {
+                throw new RuntimeException("codePointBefore(CharSequence, " + i + ") returned "
+                                           + toHexString(c)
+                                           + ", expected " + toHexString(codepoints[j]));
+            }
+        }
+        if (j != 0) {
+            throw new RuntimeException("j != 0 after codePointBefore(CharSequence, int)"
+                                       + " (j=" + j + ")");
+        }
+
+        // Test Character.codePointAt/Before(char[], int)
+        char[] a = str.toCharArray();
+        j = 0;
+        for (int i = 0; i < a.length; i += Character.charCount(c)) {
+            c = Character.codePointAt(a, i);
+            if (c != codepoints[j++]) {
+                throw new RuntimeException("codePointAt(char[], " + i + ") returned "
+                                           + toHexString(c)
+                                           + ", expected " + toHexString(codepoints[j-1]));
+            }
+        }
+        if (j != codepoints.length) {
+            throw new RuntimeException("j != codepoints.length after codePointAt(char[], int)"
+                                       + " (j=" + j + ")"
+                                       + ", expected: " + codepoints.length);
+        }
+
+        j = codepoints.length;
+        for (int i = a.length; i > 0 ; i -= Character.charCount(c)) {
+            c = Character.codePointBefore(a, i);
+            if (c != codepoints[--j]) {
+                throw new RuntimeException("codePointBefore(char[], " + i + ") returned "
+                                           + toHexString(c)
+                                           + ", expected " + toHexString(codepoints[j]));
+            }
+        }
+        if (j != 0) {
+            throw new RuntimeException("j != 0 after codePointBefore(char[], int)"
+                                       + " (j=" + j + ")");
+        }
+
+        // Test toChar(int)
+        j = 0;
+        for (int i = 0; i < codepoints.length; i++) {
+            a = Character.toChars(codepoints[i]);
+            for (int k = 0; k < a.length; k++) {
+                if (str.charAt(j++) != a[k]) {
+                    throw new RuntimeException("toChars(int) returned " + toHexString("result", a)
+                                               + " from codepoint=" + toHexString(codepoints[i]));
+                }
+            }
+        }
+
+        // Test toChars(int, char[], int)
+        a = new char[codepoints.length * 2];
+        j = 0;
+        for (int i = 0; i < codepoints.length; i++) {
+            int n = Character.toChars(codepoints[i], a, j);
+            j += n;
+        }
+        String s = new String(a, 0, j);
+        if (!str.equals(s)) {
+            throw new RuntimeException("toChars(int, char[], int) returned "
+                                       + toHexString("dst", s.toCharArray())
+                                       + ", expected " + toHexString("data", str.toCharArray()));
+        }
+    }
+
+    // Test toChar(int)
+    //      toChar(int, char[], int)
+    // for exceptions
+    static void testExceptions00() {
+        callToChars1(-1, IllegalArgumentException.class);
+        callToChars1(MAX_SUPPLEMENTARY + 1, IllegalArgumentException.class);
+
+        callToChars3(MAX_SUPPLEMENTARY, null, 0, NullPointerException.class);
+        callToChars3(-MIN_SUPPLEMENTARY,    new char[2], 0, IllegalArgumentException.class);
+        callToChars3(MAX_SUPPLEMENTARY + 1, new char[2], 0, IllegalArgumentException.class);
+        callToChars3('A', new char[0],  0, IndexOutOfBoundsException.class);
+        callToChars3('A', new char[1], -1, IndexOutOfBoundsException.class);
+        callToChars3('A', new char[1],  1, IndexOutOfBoundsException.class);
+        callToChars3(MIN_SUPPLEMENTARY, new char[0],  0, IndexOutOfBoundsException.class);
+        callToChars3(MIN_SUPPLEMENTARY, new char[1],  0, IndexOutOfBoundsException.class);
+        callToChars3(MIN_SUPPLEMENTARY, new char[2], -1, IndexOutOfBoundsException.class);
+        callToChars3(MIN_SUPPLEMENTARY, new char[2],  1, IndexOutOfBoundsException.class);
+    }
+
+    static final boolean At = true, Before = false;
+
+    /**
+     * Test codePointAt(CharSequence, int)
+     *      codePointBefore(CharSequence, int)
+     *      codePointCount(CharSequence, int, int)
+     *      offsetByCodePoints(CharSequence, int, int)
+     * for exceptions
+     */
+    static void testExceptions01(CharSequence cs) {
+        CharSequence nullSeq = null;
+        // codePointAt
+        callCodePoint(At, nullSeq, 0, NullPointerException.class);
+        callCodePoint(At, cs, -1, IndexOutOfBoundsException.class);
+        callCodePoint(At, cs, cs.length(), IndexOutOfBoundsException.class);
+        callCodePoint(At, cs, cs.length()*3, IndexOutOfBoundsException.class);
+
+        // codePointBefore
+        callCodePoint(Before, nullSeq, 0, NullPointerException.class);
+        callCodePoint(Before, cs, -1, IndexOutOfBoundsException.class);
+        callCodePoint(Before, cs, 0, IndexOutOfBoundsException.class);
+        callCodePoint(Before, cs, cs.length()+1, IndexOutOfBoundsException.class);
+
+        // codePointCount
+        callCodePointCount(nullSeq, 0, 0, NullPointerException.class);
+        callCodePointCount(cs, -1, 1, IndexOutOfBoundsException.class);
+        callCodePointCount(cs, 0, cs.length()+1, IndexOutOfBoundsException.class);
+        callCodePointCount(cs, 3, 1, IndexOutOfBoundsException.class);
+
+        // offsetByCodePoints
+        callOffsetByCodePoints(nullSeq, 0, 0, NullPointerException.class);
+        callOffsetByCodePoints(cs, -1, 1, IndexOutOfBoundsException.class);
+        callOffsetByCodePoints(cs, cs.length()+1, 1, IndexOutOfBoundsException.class);
+        callOffsetByCodePoints(cs, 0, cs.length()*2, IndexOutOfBoundsException.class);
+        callOffsetByCodePoints(cs, cs.length(), 1, IndexOutOfBoundsException.class);
+        callOffsetByCodePoints(cs, 0, -1, IndexOutOfBoundsException.class);
+        callOffsetByCodePoints(cs, cs.length(), -cs.length()*2,
+                               IndexOutOfBoundsException.class);
+        callOffsetByCodePoints(cs, cs.length(), Integer.MIN_VALUE,
+                               IndexOutOfBoundsException.class);
+        callOffsetByCodePoints(cs, 0, Integer.MAX_VALUE, IndexOutOfBoundsException.class);
+    }
+
+    /**
+     * Test codePointAt(char[], int)
+     *      codePointAt(char[], int, int)
+     *      codePointBefore(char[], int)
+     *      codePointBefore(char[], int, int)
+     *      codePointCount(char[], int, int)
+     *      offsetByCodePoints(char[], int, int, int, int)
+     * for exceptions
+     */
+    static void testExceptions02(char[] a) {
+        char[] nullArray = null;
+        callCodePoint(At, nullArray, 0, NullPointerException.class);
+        callCodePoint(At, a, -1, IndexOutOfBoundsException.class);
+        callCodePoint(At, a, a.length, IndexOutOfBoundsException.class);
+        callCodePoint(At, a, a.length*3, IndexOutOfBoundsException.class);
+        callCodePoint(Before, nullArray, 0, NullPointerException.class);
+        callCodePoint(Before, a, -1, IndexOutOfBoundsException.class);
+        callCodePoint(Before, a, 0, IndexOutOfBoundsException.class);
+        callCodePoint(Before, a, a.length+1, IndexOutOfBoundsException.class);
+
+        // tests for the methods with limit
+        callCodePoint(At, nullArray, 0, 1, NullPointerException.class);
+        callCodePoint(At, a, 0, -1, IndexOutOfBoundsException.class);
+        callCodePoint(At, a, 0, 0, IndexOutOfBoundsException.class);
+        callCodePoint(At, a, 0, a.length+1, IndexOutOfBoundsException.class);
+        callCodePoint(At, a, 2, 1, IndexOutOfBoundsException.class);
+        callCodePoint(At, a, -1, 1, IndexOutOfBoundsException.class);
+        callCodePoint(At, a, a.length, 1, IndexOutOfBoundsException.class);
+        callCodePoint(At, a, a.length*3, 1, IndexOutOfBoundsException.class);
+        callCodePoint(Before, nullArray, 1, 0, NullPointerException.class);
+        callCodePoint(Before, a, 2, -1, IndexOutOfBoundsException.class);
+        callCodePoint(Before, a, 2, 2, IndexOutOfBoundsException.class);
+        callCodePoint(Before, a, 2, 3, IndexOutOfBoundsException.class);
+        callCodePoint(Before, a, 2, a.length, IndexOutOfBoundsException.class);
+        callCodePoint(Before, a, -1, -1, IndexOutOfBoundsException.class);
+        callCodePoint(Before, a, 0, 0, IndexOutOfBoundsException.class);
+        callCodePoint(Before, a, a.length+1, a.length-1, IndexOutOfBoundsException.class);
+
+        // codePointCount
+        callCodePointCount(nullArray, 0, 0, NullPointerException.class);
+        callCodePointCount(a, -1, 1, IndexOutOfBoundsException.class);
+        callCodePointCount(a, 0, -1, IndexOutOfBoundsException.class);
+        callCodePointCount(a, 0, a.length+1, IndexOutOfBoundsException.class);
+        callCodePointCount(a, 1, a.length, IndexOutOfBoundsException.class);
+        callCodePointCount(a, a.length, 1, IndexOutOfBoundsException.class);
+        callCodePointCount(a, a.length+1, -1, IndexOutOfBoundsException.class);
+
+        // offsetByCodePoints
+        callOffsetByCodePoints(nullArray, 0, 0, 0, 0,  NullPointerException.class);
+        callOffsetByCodePoints(a, -1, a.length, 1, 1, IndexOutOfBoundsException.class);
+        callOffsetByCodePoints(a, 0, a.length+1, 1, 1, IndexOutOfBoundsException.class);
+        callOffsetByCodePoints(a, 10, a.length, 1, 1, IndexOutOfBoundsException.class);
+        callOffsetByCodePoints(a, 10, a.length-10, 1, 1, IndexOutOfBoundsException.class);
+        callOffsetByCodePoints(a, 10, 10, 21, 1, IndexOutOfBoundsException.class);
+        callOffsetByCodePoints(a, 20, -10, 15, 1, IndexOutOfBoundsException.class);
+        callOffsetByCodePoints(a, 10, 10, 15, 20, IndexOutOfBoundsException.class);
+        callOffsetByCodePoints(a, 10, 10, 15, -20, IndexOutOfBoundsException.class);
+        callOffsetByCodePoints(a, 0, a.length, -1, 1, IndexOutOfBoundsException.class);
+        callOffsetByCodePoints(a, 0, a.length, a.length+1, 1, IndexOutOfBoundsException.class);
+        callOffsetByCodePoints(a, 0, a.length, 0, a.length*2, IndexOutOfBoundsException.class);
+        callOffsetByCodePoints(a, 0, a.length, a.length, 1, IndexOutOfBoundsException.class);
+        callOffsetByCodePoints(a, 0, a.length, 0, -1, IndexOutOfBoundsException.class);
+        callOffsetByCodePoints(a, 0, a.length, a.length, -a.length*2,
+                               IndexOutOfBoundsException.class);
+        callOffsetByCodePoints(a, 0, a.length, a.length, Integer.MIN_VALUE,
+                               IndexOutOfBoundsException.class);
+        callOffsetByCodePoints(a, 0, a.length, 0, Integer.MAX_VALUE,
+                               IndexOutOfBoundsException.class);
+    }
+
+    /**
+     * Test the 1-arg toChars(int) for exceptions
+     */
+    private static void callToChars1(int codePoint, Class expectedException) {
+        try {
+            char[] a = Character.toChars(codePoint);
+        } catch (Exception e) {
+            if (expectedException.isInstance(e)) {
+                return;
+            }
+            throw new RuntimeException("Unspecified exception", e);
+        }
+        throw new RuntimeException("toChars(int) didn't throw " + expectedException.getName());
+    }
+
+    /**
+     * Test the 3-arg toChars(int, char[], int) for exceptions
+     */
+    private static void callToChars3(int codePoint, char[] dst, int index,
+                                     Class expectedException) {
+        try {
+            int n = Character.toChars(codePoint, dst, index);
+        } catch (Exception e) {
+            if (expectedException.isInstance(e)) {
+                return;
+            }
+            throw new RuntimeException("Unspecified exception", e);
+        }
+        throw new RuntimeException("toChars(int,char[],int) didn't throw "
+                                   + expectedException.getName());
+    }
+
+    private static void callCodePoint(boolean isAt, CharSequence cs, int index,
+                                      Class expectedException) {
+        try {
+            int c = isAt ? Character.codePointAt(cs, index)
+                         : Character.codePointBefore(cs, index);
+        } catch (Exception e) {
+            if (expectedException.isInstance(e)) {
+                return;
+            }
+            throw new RuntimeException("Unspecified exception", e);
+        }
+        throw new RuntimeException("codePoint" + (isAt ? "At" : "Before")
+                                   + " didn't throw " + expectedException.getName());
+    }
+
+    private static void callCodePoint(boolean isAt, char[] a, int index,
+                                      Class expectedException) {
+        try {
+            int c = isAt ? Character.codePointAt(a, index)
+                         : Character.codePointBefore(a, index);
+        } catch (Exception e) {
+            if (expectedException.isInstance(e)) {
+                return;
+            }
+            throw new RuntimeException("Unspecified exception", e);
+        }
+        throw new RuntimeException("codePoint" + (isAt ? "At" : "Before")
+                                   + " didn't throw " + expectedException.getName());
+    }
+
+    private static void callCodePoint(boolean isAt, char[] a, int index, int limit,
+                                      Class expectedException) {
+        try {
+            int c = isAt ? Character.codePointAt(a, index, limit)
+                         : Character.codePointBefore(a, index, limit);
+        } catch (Exception e) {
+            if (expectedException.isInstance(e)) {
+                return;
+            }
+            throw new RuntimeException("Unspecified exception", e);
+        }
+        throw new RuntimeException("codePoint" + (isAt ? "At" : "Before")
+                                   + " didn't throw " + expectedException.getName());
+    }
+
+    private static void callCodePointCount(Object data, int beginIndex, int endIndex,
+                                           Class expectedException) {
+        String type = getType(data);
+        try {
+            int n = (data instanceof CharSequence) ?
+                  Character.codePointCount((CharSequence) data, beginIndex, endIndex)
+                : Character.codePointCount((char[]) data, beginIndex, endIndex);
+        } catch (Exception e) {
+            if (expectedException.isInstance(e)) {
+                return;
+            }
+            throw new RuntimeException("Unspecified exception", e);
+        }
+        throw new RuntimeException("codePointCount(" + type + "...) didn't throw "
+                                   + expectedException.getName());
+    }
+
+    private static void callOffsetByCodePoints(CharSequence seq, int index, int offset,
+                                               Class expectedException) {
+        try {
+            int n = Character.offsetByCodePoints(seq, index, offset);
+        } catch (Exception e) {
+            if (expectedException.isInstance(e)) {
+                return;
+            }
+            throw new RuntimeException("Unspecified exception", e);
+        }
+        throw new RuntimeException("offsetCodePointCounts(CharSequnce...) didn't throw "
+                                   + expectedException.getName());
+    }
+
+
+    private static void callOffsetByCodePoints(char[] a, int start, int count,
+                                               int index, int offset,
+                                               Class expectedException) {
+        try {
+            int n = Character.offsetByCodePoints(a, start, count, index, offset);
+        } catch (Exception e) {
+            if (expectedException.isInstance(e)) {
+                return;
+            }
+            throw new RuntimeException("Unspecified exception", e);
+        }
+        throw new RuntimeException("offsetCodePointCounts(char[]...) didn't throw "
+                                   + expectedException.getName());
+    }
+
+    private static String getType(Object data) {
+        return (data instanceof CharSequence) ? "CharSequence" : "char[]";
+    }
+
+    private static String toHexString(int c) {
+        return "0x" + Integer.toHexString(c);
+    }
+
+    private static String toHexString(String name, char[] a) {
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0; i < a.length; i++) {
+            if (i > 0) {
+                sb.append(", ");
+            }
+            sb.append(name).append('[').append(i).append("]=");
+            sb.append(toHexString(a[i]));
+        }
+        return sb.toString();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/Character/TestISOControls.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,52 @@
+/*
+ * 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");
+
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/Character/TestNegativeCodepoint.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,97 @@
+/*
+ * 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 4899380
+ * @summary Character.is<Property>(int codePoint) methods should return false
+ *          for negative codepoint values. The to<CaseMap> methods should return
+ *          the original codePoint for invalid codePoint ranges.
+ * @author John O'Conner
+ */
+
+public class TestNegativeCodepoint {
+
+    public static void main(String[] args) {
+
+      int[] invalidCodePoints = { -1, -'a', 0x110000};
+      for (int x = 0; x < invalidCodePoints.length; ++x) {
+        int cp = invalidCodePoints[x];
+
+        System.out.println("Testing codepoint: " + cp);
+         // test all of the is<Property> methods
+        if (Character.isLowerCase(cp) ||
+            Character.isUpperCase(cp) ||
+            Character.isTitleCase(cp) ||
+            Character.isISOControl(cp) ||
+            Character.isLetterOrDigit(cp) ||
+            Character.isLetter(cp) ||
+            Character.isDigit(cp) ||
+            Character.isDefined(cp) ||
+            Character.isJavaIdentifierStart(cp) ||
+            Character.isJavaIdentifierPart(cp) ||
+            Character.isUnicodeIdentifierStart(cp) ||
+            Character.isUnicodeIdentifierPart(cp) ||
+            Character.isIdentifierIgnorable(cp) ||
+            Character.isSpaceChar(cp) ||
+            Character.isWhitespace(cp) ||
+            Character.isMirrored(cp) ||
+
+            // test the case mappings
+            Character.toLowerCase(cp) != cp ||
+            Character.toUpperCase(cp) != cp ||
+            Character.toTitleCase(cp) != cp ||
+
+            // test directionality of invalid codepoints
+            Character.getDirectionality(cp) != Character.DIRECTIONALITY_UNDEFINED ||
+
+            // test type
+            Character.getType(cp) != Character.UNASSIGNED ||
+
+            // test numeric and digit  values
+            Character.getNumericValue(cp) != -1 ||
+            Character.digit(cp, 10) != -1 ) {
+
+            System.out.println("Failed.");
+            throw new RuntimeException();
+        }
+
+        // test block value
+        Character.UnicodeBlock block = null;
+        try {
+            block = Character.UnicodeBlock.of(cp);
+            // if we haven't already thrown an exception because of the illegal
+            // arguments, then we need to throw one because of an error in the of() method
+            System.out.println("Failed.");
+            throw new RuntimeException();
+        }
+        catch(IllegalArgumentException e) {
+            // Since we're testing illegal values, we
+            // expect to land here every time. If not,
+            // our test has failed
+        }
+
+      }
+      System.out.println("Passed.");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/Character/TestUndefinedDirectionality.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,52 @@
+/*
+ * 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     4427146
+ * @summary Undefined char values should have DIRECTIONALITY_UNDEFINED.
+ * @author  John O'Conner
+ */
+
+public class TestUndefinedDirectionality {
+
+    public static void main(String[] args) {
+        int failures = 0;
+        for (int ch=0x0000;ch <= 0xFFFF; ch++) {
+            if (!Character.isDefined((char)ch)) {
+                byte direction = Character.getDirectionality((char)ch);
+                if (direction != Character.DIRECTIONALITY_UNDEFINED) {
+                    System.err.println("Fail: \\u" + Integer.toString(ch, 16));
+                    failures++;
+                }
+            }
+        }
+        if (failures != 0) {
+            throw new RuntimeException("TestUndefinedDirectionality: failed.");
+        } else {
+            System.out.println("Passed.");
+        }
+
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/Character/TestUndefinedIdentifierStartPart.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,46 @@
+/*
+ * 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 4453719
+ * @author John O'Conner
+ * @summary Undefined char values cannot be Java identifier starts or parts.
+ */
+
+public class TestUndefinedIdentifierStartPart {
+    static int endValue = 0xFFFF;
+
+    public static void main(String[] args) {
+        for (int ch=0x0000; ch <= endValue; ch++) {
+            if (!Character.isDefined((char)ch) &&
+                    (Character.isJavaIdentifierStart((char)ch) ||
+                     Character.isJavaIdentifierPart((char)ch) ||
+                     Character.isUnicodeIdentifierStart((char)ch) ||
+                     Character.isUnicodeIdentifierPart((char)ch))) {
+                throw new RuntimeException("Char value " + Integer.toHexString((char)ch));
+            }
+        }
+        System.out.println("Passed");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/Character/TestUndefinedIgnorable.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,46 @@
+/*
+ * 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 4453719
+ * @author John O'Conner
+ * @summary Undefined character values should not be ignorable identifiers.
+ */
+
+public class TestUndefinedIgnorable {
+    static int endValue = 0xFFFF;
+
+    public static void main(String[] args) {
+
+        for (int ch=0x0000; ch <= endValue; ch++) {
+            if (!Character.isDefined((char)ch) &&
+                    Character.isIdentifierIgnorable((char)ch)) {
+                throw new RuntimeException("Char value " + Integer.toHexString((char)ch));
+            }
+        }
+        System.out.println("Passed.");
+
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/Character/TestUndefinedMirrored.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,42 @@
+/*
+ * 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 4453720
+ * @author John O'Conner
+ * @summary Undefined char values should not have mirrored property.
+ */
+
+public class TestUndefinedMirrored {
+    static int endValue = 0xFFFF;
+
+    public static void main(String[] args) {
+        for (int ch = 0x0000; ch <= endValue; ch++) {
+            if (!Character.isDefined((char)ch) && Character.isMirrored((char)ch)) {
+                throw new RuntimeException("Char value " + Integer.toHexString((char)ch));
+            }
+        }
+        System.out.println("Passed.");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/Character/TestUndefinedNumeric.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,46 @@
+/*
+ * 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 4453721
+ * @author John O'Conner
+ * @summary Unassigned char values should have no numeric properties.
+ */
+
+public class TestUndefinedNumeric {
+    static int endValue = 0xFFFF;
+
+    public static void main(String[] args) {
+        for (int ch = 0x0000; ch <= 0xFFFF; ch++) {
+            if (!Character.isDefined((char)ch) &&
+                    Character.getNumericValue((char)ch) != -1) {
+                throw new RuntimeException("Char value " + Integer.toHexString((char)ch));
+
+            }
+
+        }
+        System.out.println("Passed.");
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/Character/TestUndefinedTitleCase.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,42 @@
+/*
+ * 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
+ * @author John O'Conner
+ * @bug 4453730
+ * @summary Undefined character code points do not have titlecase mappings. The
+ *          toTitleCase method should return the argument code value.
+ */
+public class TestUndefinedTitleCase {
+    static int endCharValue = 0xFFFF;
+
+    public static void main(String[] args) {
+        for(int ch=0x0000; ch <= endCharValue; ch++) {
+            if (!Character.isDefined((char)ch) && Character.toTitleCase((char)ch) != (char)ch) {
+                throw new RuntimeException("Char value " + Integer.toHexString((char)ch));
+            }
+        }
+        System.out.println("Passed");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/Character/TestWhiteSpace.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,46 @@
+/*
+ * 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     4427146
+ * @summary Some char values that are Unicode spaces are non-breaking. These
+ *          should not be Java whitespaces.
+ * @author  John O'Conner
+ */
+
+public class TestWhiteSpace {
+
+    public static void main(String[] args) {
+        // These values should NOT be whitespace
+        char[] whiteSpace = {'\u00A0', '\u2007', '\u202F'};
+
+        for (int x=0;x<whiteSpace.length;x++) {
+            if (Character.isWhitespace(whiteSpace[x])) {
+                throw new RuntimeException("Invalid whitespace: \\u" +
+                    Integer.toString((int)whiteSpace[x], 16));
+            }
+        }
+        System.out.println("Passed.");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/Package/A.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+package p;
+
+public class A {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/Package/IsCompatibleWith.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,89 @@
+/*
+ * 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.
+ */
+
+public class IsCompatibleWith {
+    private static boolean fail = false;
+    private static Package p = p.A.class.getPackage();
+
+    public static void main(String [] args) {
+        IsCompatibleWith s = new IsCompatibleWith();
+
+        s.ex("");
+        s.ex("x.31");
+        s.ex("5....");
+        s.ex("10.3a");
+        s.ex("2.-2");
+        s.ex("-1.0");
+        s.ex(".01");
+
+        s.t("0");
+        s.t("1.4");
+        s.t("1.4.0");
+        s.f("1.415");
+        s.t("1.3.1.0.0.0.0.7");
+        s.t("1.2.02");
+        s.f("1.4.35");
+        s.f("33.0");
+
+        s.f(new Integer(Integer.MAX_VALUE).toString());
+        s.ex("2147483648");  // Integer.MAX_VALUE + 1
+
+        if (fail == true)
+            throw new RuntimeException("Test FAILED");
+        else
+            System.out.println("Test PASSED");
+    }
+
+    // NumberFormatException expected
+    private void ex(String s) {
+        try {
+            p.isCompatibleWith(s);
+        } catch (NumberFormatException e) {
+            System.out.println("PASS: \"" + s + "\"");
+            e.printStackTrace(System.out);
+            return;
+        }
+        fail = true;
+        System.err.println("FAIL: Exception missing: \"" + s + "\"");
+    }
+
+    // "true" or "false" expected
+    private void t(String s) { test(s, true);  }
+    private void f(String s) { test(s, false); }
+
+    private void test(String s, boolean expect) {
+        try {
+            if (p.isCompatibleWith(s) != expect) {
+                System.err.println("FAIL: \"" + s + "\", expected: " + expect);
+                fail = true;
+                return;
+            }
+        } catch (Exception e) {
+            System.err.println("FAIL: \"" + s + "\"");
+            e.printStackTrace();
+            fail = true;
+            return;
+        }
+        System.out.println("PASS: \"" + s + "\"");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/Package/IsCompatibleWithDriver.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,63 @@
+/*
+ * 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 4227825 4785473
+ * @summary Test behaviour of Package.isCompatibleWith().
+ * @library /lib/testlibrary
+ * @library /test/lib
+ * @build A IsCompatibleWith
+ *        JarUtils
+ *        jdk.test.lib.process.*
+ * @run main IsCompatibleWithDriver
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.jar.Manifest;
+
+import static java.io.File.pathSeparator;
+
+import java.io.InputStream;
+import java.nio.file.Files;
+
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
+public class IsCompatibleWithDriver {
+    public static void main(String args[]) throws Throwable {
+        Path classes = Paths.get(System.getProperty("test.classes", ""));
+        Path manifest = Paths.get(System.getProperty("test.src"), "test.mf");
+        try (InputStream is = Files.newInputStream(manifest)) {
+            JarUtils.createJarFile(Paths.get("test.jar"), new Manifest(is),
+                    classes, classes.resolve("p"));
+        }
+        Files.delete(classes.resolve("p").resolve("A.class"));
+
+        OutputAnalyzer analyzer = ProcessTools.executeTestJava("-cp",
+                "test.jar" + pathSeparator + classes.toString(), "IsCompatibleWith");
+        System.out.println(analyzer.getOutput());
+        analyzer.shouldHaveExitValue(0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/Package/test.mf	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,2 @@
+Manifest-version: 1.0
+Specification-Version: 1.4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/Runtime/Resources.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,44 @@
+/*
+ * 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 4349850
+ * @summary java.lang.Runtime.maxMemory()/availableProcessors()
+ */
+
+import java.io.PrintStream;
+
+public class Resources {
+
+    static PrintStream out = System.err;
+
+    public static void main(String args[]) throws Exception {
+        Runtime rt = Runtime.getRuntime();
+        out.println(rt.freeMemory() + " bytes free");
+        out.println(rt.totalMemory() + "  bytes in use");
+        out.println(rt.maxMemory() + " bytes max");
+        out.println(rt.availableProcessors() + " processors");
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/Runtime/shutdown/Basic.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,263 @@
+/*
+ * 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 4227137
+ * @summary Basic functional test for virtual-machine shutdown hooks
+ * @modules java.desktop
+ * @library /test/lib
+ * @build jdk.test.lib.process.*
+ * @run testng Basic
+ */
+
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+import java.io.PrintStream;
+import java.io.FileOutputStream;
+import java.awt.Frame;
+import java.awt.TextArea;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowAdapter;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import jdk.test.lib.process.ProcessTools;
+
+public class Basic {
+
+    static Runtime rt = Runtime.getRuntime();
+    static PrintStream out = System.out;
+
+    @DataProvider(name = "testcase")
+    public Object[][] getTestCase() {
+        return new Object[][] {
+            { "fallThrough", 0, "h1", "f1" },
+            { "exit0",       0, "h1", "f1" },
+            { "exit0NoHook", 0, "",   "f1" },
+            { "exit1",       1, "h1", "" },
+            { "exit1NoHook", 1, "",   "" },
+            { "halt",        0, "",   "" },
+            { "haltNoHook",  0, "",   "" },
+            { "haltInHook",  0, "h1", "" },
+            { "addLate",     0, "h1",
+                "Caught as expected: java.lang.IllegalStateException: Shutdown in progress" },
+            { "removeLate",  0, "h2",
+                "Caught as expected: java.lang.IllegalStateException: Shutdown in progress" }
+        };
+    }
+
+    @Test(dataProvider = "testcase")
+    public void test(String testcase, int exitValue, String hook, String finalizer)
+            throws Exception {
+        System.out.println("Test " + testcase);
+        ProcessTools.executeTestJava("Basic", testcase)
+                .shouldHaveExitValue(exitValue)
+                .stdoutShouldMatch(
+                    hook + (hook.isEmpty() ? "" : System.lineSeparator()) + finalizer);
+        System.out.println("Passed");
+    }
+
+    public static class Fin {
+        String name;
+
+        public Fin(String name) {
+            this.name = name;
+        }
+
+        public void go() { }
+
+        protected void finalize() {
+            out.println(name);
+            go();
+        }
+    }
+
+
+    public static class Hook extends Thread {
+        String name;
+
+        public Hook(String name) {
+            this.name = name;
+        }
+
+        public void go() { }
+
+        public void run() {
+            out.println(name);
+            go();
+        }
+    }
+
+    public static void fallThrough() throws Exception {
+        rt.addShutdownHook(new Hook("h1"));
+        Fin f = new Fin("f1");
+        rt.runFinalizersOnExit(true);
+    }
+
+    public static void exit0() throws Exception {
+        rt.addShutdownHook(new Hook("h1"));
+        Fin f = new Fin("f1");
+        rt.runFinalizersOnExit(true);
+        rt.exit(0);
+    }
+
+    public static void exit0NoHook() throws Exception {
+        Fin f = new Fin("f1");
+        rt.runFinalizersOnExit(true);
+        rt.exit(0);
+    }
+
+    /* Finalizer should not run */
+    public static void exit1() throws Exception {
+        rt.addShutdownHook(new Hook("h1"));
+        Fin f = new Fin("f1");
+        rt.runFinalizersOnExit(true);
+        rt.exit(1);
+    }
+
+    public static void exit1NoHook() throws Exception {
+        Fin f = new Fin("f1");
+        rt.runFinalizersOnExit(true);
+        rt.exit(1);
+    }
+
+    public static void halt() throws Exception {
+        rt.addShutdownHook(new Hook("h1") {
+            public void go() { rt.halt(1); }});
+        Fin f = new Fin("f1") { public void go() { rt.halt(1); }};
+        rt.runFinalizersOnExit(true);
+        rt.halt(0);
+    }
+
+    public static void haltNoHook() throws Exception {
+        Fin f = new Fin("f1") { public void go() { rt.halt(1); }};
+        rt.runFinalizersOnExit(true);
+        rt.halt(0);
+    }
+
+    public static void haltInHook() throws Exception {
+        rt.addShutdownHook(new Hook("h1") {
+            public void go() { rt.halt(0); }});
+        Fin f = new Fin("f1");
+        rt.runFinalizersOnExit(true);
+        rt.exit(1);
+    }
+
+    public static void addLate() throws Exception {
+        rt.addShutdownHook(new Hook("h1") {
+            public void go() {
+                try {
+                    rt.addShutdownHook(new Hook("h2"));
+                } catch (IllegalStateException x) {
+                    out.println("Caught as expected: " + x);
+                    rt.halt(0);
+                }
+            }});
+        rt.exit(1);
+    }
+
+    public static void removeLate() throws Exception {
+        final Hook h1 = new Hook("h1");
+        rt.addShutdownHook(new Hook("h2") {
+            public void go() {
+                try {
+                    rt.removeShutdownHook(h1);
+                } catch (IllegalStateException x) {
+                    out.println("Caught as expected: " + x);
+                    rt.halt(0);
+                }
+            }});
+        rt.exit(1);
+    }
+
+
+    /* The following two methods are provided for manual testing only.
+     * Neither test is suitable for being run from within the harness.
+     */
+
+    public static void awt() throws Exception {
+        final Frame f = new Frame();
+        final TextArea ta = new TextArea();
+        Fin fx = new Fin("f1");
+        rt.runFinalizersOnExit(true);
+        rt.addShutdownHook(new Hook("h1") {
+            public void go() {
+                ta.setText("Hooked!");
+                out.println("Hooked!");
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException x) { }
+                ta.append("\nSleep 1");
+                out.println("Sleep 1");
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException x) { }
+                ta.append("\nSleep 2");
+                out.println("Sleep 2");
+            }});
+        f.addWindowListener(new WindowAdapter() {
+            public void windowClosing(WindowEvent e) {
+                out.println("Closing...");
+                ta.setText("Closing...");
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException x) { }
+                f.dispose();
+                rt.exit(42);
+            }});
+        ta.setText("Terminate me!");
+        f.add(ta);
+        f.pack();
+        f.show();
+        Thread.sleep(10000);
+    }
+
+    /* For INT, HUP, TERM */
+    public static void stall() throws Exception {
+        Fin f = new Fin("f1");
+        rt.runFinalizersOnExit(true);
+        rt.addShutdownHook(new Hook("h1"));
+        out.print("Type ^C now: ");
+        out.flush();
+        Thread.sleep(100000);
+    }
+
+
+    public static void main(String[] args) throws Throwable {
+        Method m = Basic.class.getMethod(args[0], new Class[] { });
+        String log = null;
+        try {
+            log = System.getProperty("log");
+        } catch (SecurityException x) { }
+        if (log != null) {
+            out = new PrintStream(new FileOutputStream(log), true);
+        }
+        try {
+            m.invoke(null, new Object[] { });
+        } catch (InvocationTargetException x) {
+            throw x.getTargetException();
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/SecurityManager/CheckAccessClassInPackagePermissions.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,138 @@
+/*
+ * 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 8055206
+ * @summary Check that each module loaded by the platform loader has the
+ *          proper "accessClassInPackage" RuntimePermissions to access its
+ *          qualified exports.
+ * @run main CheckAccessClassInPackagePermissions
+ */
+
+import java.lang.module.ModuleDescriptor;
+import java.lang.module.ModuleDescriptor.Exports;
+import java.net.URL;
+import java.security.CodeSigner;
+import java.security.CodeSource;
+import java.security.Policy;
+import java.security.ProtectionDomain;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+public class CheckAccessClassInPackagePermissions {
+
+    private static final String[] deployModules = {
+        "jdk.javaws", "jdk.plugin", "jdk.plugin.server", "jdk.deploy" };
+
+    public static void main(String[] args) throws Exception {
+
+        // Get the modules in the boot layer loaded by the boot or platform
+        // loader
+        ModuleLayer bootLayer = ModuleLayer.boot();
+        Set<Module> modules = bootLayer.modules()
+            .stream()
+            .filter(CheckAccessClassInPackagePermissions::isBootOrPlatformMod)
+            .collect(Collectors.toSet());
+
+        // Create map of target module's qualified export packages
+        Map<String, List<String>> map = new HashMap<>();
+        Set<Exports> qualExports =
+            modules.stream()
+                   .map(Module::getDescriptor)
+                   .map(ModuleDescriptor::exports)
+                   .flatMap(Set::stream)
+                   .filter(Exports::isQualified)
+                   .collect(Collectors.toSet());
+        for (Exports e : qualExports) {
+            Set<String> targets = e.targets();
+            for (String t : targets) {
+                map.compute(t, (k, ov) -> {
+                    if (ov == null) {
+                        List<String> v = new ArrayList<>();
+                        v.add(e.source());
+                        return v;
+                    } else {
+                        ov.add(e.source());
+                        return ov;
+                    }
+                });
+            }
+        }
+
+        // Check if each target module has the right permissions to access
+        // its qualified exports
+        Policy policy = Policy.getPolicy();
+        List<String> deployMods = Arrays.asList(deployModules);
+        for (Map.Entry<String, List<String>> me : map.entrySet()) {
+            String moduleName = me.getKey();
+
+            // skip deploy modules since they are granted permissions in
+            // deployment policy file
+            if (deployMods.contains(moduleName)) {
+                continue;
+            }
+
+            // is this a module loaded by the platform loader?
+            Optional<Module> module = bootLayer.findModule(moduleName);
+            if (!module.isPresent()) {
+                continue;
+            }
+            Module mod = module.get();
+            if (mod.getClassLoader() != ClassLoader.getPlatformClassLoader()) {
+                continue;
+            }
+
+            // create ProtectionDomain simulating module
+            URL url = new URL("jrt:/" + moduleName);
+            CodeSource cs = new CodeSource(url, (CodeSigner[])null);
+            ProtectionDomain pd = new ProtectionDomain(cs, null, null, null);
+
+            List<String> pkgs = me.getValue();
+            for (String p : pkgs) {
+                RuntimePermission rp =
+                    new RuntimePermission("accessClassInPackage." + p);
+                if (!policy.implies(pd, rp)) {
+                    throw new Exception("Module " + mod + " has not been " +
+                                        "granted " + rp);
+                }
+            }
+        }
+    }
+
+    /**
+     * Returns true if the module's loader is the boot or platform loader.
+     */
+    private static boolean isBootOrPlatformMod(Module m) {
+        return m.getClassLoader() == null ||
+               m.getClassLoader() == ClassLoader.getPlatformClassLoader();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/System/ClearProperty.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,60 @@
+/*
+ * 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 4463345
+ * @summary Simple test of System.clearProperty
+ * @run main/othervm ClearProperty
+ */
+
+public class ClearProperty {
+    public static void main(String [] argv) throws Exception {
+        clearTest();
+        paramTest();
+    }
+
+    static void clearTest() throws Exception {
+        System.setProperty("blah", "blech");
+        if (!System.getProperty("blah").equals("blech"))
+            throw new RuntimeException("Clear test failed 1");
+        System.clearProperty("blah");
+        if (System.getProperty("blah") != null)
+            throw new RuntimeException("Clear test failed 2");
+    }
+
+    static void paramTest() throws Exception {
+        try {
+            System.clearProperty(null);
+            throw new RuntimeException("Param test failed");
+        } catch (NullPointerException npe) {
+            // Correct result
+        }
+        try {
+            System.clearProperty("");
+            throw new RuntimeException("Param test failed");
+        } catch (IllegalArgumentException iae) {
+            // Correct result
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/System/NonAnsiFileEncodingTest.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,63 @@
+/*
+ * 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 4459099
+ * @key i18n
+ * @summary Tests non ANSI code page locales set default file encoding
+ * to "utf-8".  This test must be run on Windows 2K/XP in one of Armenian,
+ * Georgian, Hindi, Punjabi, Gujarati, Tamil, Telugu, Kannada, Marathi,
+ * or Sanskrit languages.
+ */
+
+public class NonAnsiFileEncodingTest {
+    public static void main(String[] s)  {
+        String OS = System.getProperty("os.name");
+        String lang = System.getProperty("user.language");
+        String fileenc = System.getProperty("file.encoding");
+
+        if (!(OS.equals("Windows 2000") || OS.equals("Windows XP"))) {
+            System.out.println("This test is not meaningful on the platform \"" + OS + "\".");
+            return;
+        }
+
+        if (!(lang.equals("hy") ||      // Armenian
+              lang.equals("ka") ||      // Georgian
+              lang.equals("hi") ||      // Hindi
+              lang.equals("pa") ||      // Punjabi
+              lang.equals("gu") ||      // Gujarati
+              lang.equals("ta") ||      // Tamil
+              lang.equals("te") ||      // Telugu
+              lang.equals("kn") ||      // Kannada
+              lang.equals("mr") ||      // Marathi
+              lang.equals("sa"))) {     // Sanskrit
+            System.out.println("Windows' locale settings for this test is incorrect.  Select one of \"Armenian\", \"Georgian\", \"Hindi\", \"Punjabi\", \"Gujarati\", \"Tamil\", \"Telugu\", \"Kannada\", \"Marathi\", or \"Sanskrit\" for the user locale, and \"English(United States)\" for the system default locale using the Control Panel.");
+            return;
+        }
+
+        if (!fileenc.equals("utf-8")) {
+            throw new RuntimeException("file.encoding is incorrectly set to \"" + fileenc + "\".  Should be \"utf-8\".");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/System/SetProperties.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,37 @@
+/*
+ * 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 4244670
+ * @summary test System.setProperties(null)
+ */
+
+import java.util.Properties;
+
+public class SetProperties {
+    public static void main(String [] argv) {
+        System.setProperties((Properties)null);
+        System.getProperties().containsKey("java.version");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/jdk/internal/loader/InterruptedClassLoad.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,37 @@
+/*
+ * 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     4764778
+ * @summary Mishandling interruption of I/O in Resource.getBytes
+ * @author  Martin Buchholz
+ */
+
+public class InterruptedClassLoad {
+    public static void main(String[] args) {
+        class Empty {}
+        Thread.currentThread().interrupt();
+        new Empty();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/jdk/internal/math/ToString.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,73 @@
+/*
+ * 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
+ * @modules java.base/jdk.internal.math
+ */
+
+import jdk.internal.math.FloatingDecimal;
+
+public class ToString {
+    private static int fail = 0;
+
+    private static Throwable first;
+
+    public static void main(String argv[]) {
+        test("10.0");
+        test("1.0");
+        test("0.1");
+        test("0.01");
+        test("0.001");
+        test("1.0E-4");
+        if (fail != 0)
+            throw new RuntimeException(fail + " failure(s), first", first);
+    }
+
+    private static void test(String exp) {
+        float c = Float.parseFloat(exp);
+        String got = FloatingDecimal.toJavaFormatString(c);
+        if (!got.equals(exp))
+            fail("float '" + "': Expected '" + exp + "', got '" + got + "'");
+
+        double d = Double.parseDouble(exp);
+        got = FloatingDecimal.toJavaFormatString(d);
+        if (!got.equals(exp))
+            fail("double '" + "': Expected '" + exp + "', got '" + got + "'");
+    }
+
+    private static void fail(String s) {
+        if (first == null)
+            setFirst(s);
+        System.err.println("FAILED: " + s);
+        fail++;
+    }
+
+    private static void setFirst(String s) {
+        try {
+            throw new RuntimeException(s);
+        } catch (RuntimeException x) {
+            first = x;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/vm/gc/ArraySize.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,46 @@
+/*
+ * 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 4063078
+ * @summary Allocating a ridiculously large array should not crash the VM
+ * @run main/othervm -Xmx32m -Xms32m ArraySize
+ */
+
+public class ArraySize {
+
+    public static void main(String[] args) throws Exception {
+        boolean thrown = false;
+        try {
+            byte[] buf = new byte[Integer.MAX_VALUE - 1];
+            System.out.print(buf[0]);
+        } catch (OutOfMemoryError x) {
+            thrown = true;
+        }
+        if (! thrown) {
+            throw new Exception("Didn't throw expected OutOfMemoryError");
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/vm/gc/InfiniteList.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,49 @@
+/*
+ * 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 4098578
+ * @summary Check if the VM properly throws OutOfMemoryError
+ * @author Sheng Liang
+ * @run main/othervm -Xmx25M InfiniteList
+ */
+public class InfiniteList {
+    InfiniteList next;
+    long data[] = new long[50000];
+    public static void main(String[] args) throws Exception {
+        InfiniteList p, q;
+        p = new InfiniteList ();
+        p.data[p.data.length -1 ] = 999;
+        try {
+            while (p != null) {
+                q = new InfiniteList ();
+                q.next = p;
+                p = q;
+            }
+            throw new Exception ("OutOfMemoryError not thrown as expected.");
+        } catch (OutOfMemoryError e) {
+            return;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/vm/jit/BadLogicCode.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,58 @@
+/*
+ * 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 4157675
+ * @summary Solaris JIT generates bad code for logic expression
+ * @author Tom Rodriguez
+ */
+
+public class BadLogicCode {
+    static int values[] = {Integer.MIN_VALUE, -1, 0, 1, 4, 16, 31,
+                           32, 33, Integer.MAX_VALUE};
+    static char b[][] = {null, new char[32]};
+    static boolean nullPtr = false, indexOutBnd = false;
+    static boolean indexOutBnd2 = false;
+
+    public static void main(String args[]) throws Exception{
+        int i = 1, j = 4, k = 9;
+
+        nullPtr = (b[i] == null);
+
+        int bufLen = nullPtr ? 0 : b[i].length;
+        indexOutBnd = (values[j] < 0)
+            || (values[j] > bufLen)
+            || (values[k] < 0)
+            || ((values[j] + values[k]) > bufLen)
+            ||((values[j] + values[k]) < 0);
+
+        indexOutBnd2 = (values[j] < 0);
+        indexOutBnd2 = indexOutBnd2 || (values[j] > bufLen);
+        indexOutBnd2 = indexOutBnd2 || (values[k] < 0);
+        indexOutBnd2 = indexOutBnd2 || ((values[j] + values[k]) > bufLen);
+        indexOutBnd2 = indexOutBnd2 ||((values[j] + values[k]) < 0);
+        if (indexOutBnd != indexOutBnd2)
+            throw new Error("logic expression generate different results");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/vm/jit/ExceptionInInit.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,93 @@
+/*
+ * 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 4165973
+ * @summary Attempt to read inaccessible property can produce
+ *          exception of the wrong type.
+ * @author Tom Rodriguez
+ *
+ * @modules java.rmi
+ */
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+public class ExceptionInInit {
+
+    public static void main(String[] args) {
+
+        Test test = null;
+
+        try {
+            System.setSecurityManager(new java.rmi.RMISecurityManager());
+            Test.showTest();
+        } catch (ExceptionInInitializerError e) {
+        }
+    }
+
+    public static class FooBar {
+        static String test = "test";
+        FooBar(String test) {
+            this.test = test;
+        }
+    }
+
+    public static class Test extends FooBar {
+
+        /*
+         * An AccessControlException is thrown in the static initializer of the
+         * class FooBar. This exception should produce an ExceptionInInitializer
+         * error. Instead it causes a more cryptic ClassNotFound error.
+         *
+         * The following is an excerpt from the output from java.security.debug=all
+         *
+         * access: access denied (java.util.PropertyPermission test.src read)
+         * java.lang.Exception: Stack trace
+         *         at java.lang.Thread.dumpStack(Thread.java:938)
+         *         at java.security.AccessControlContext.checkPermission(AccessControlContext.java:184)
+         *         at java.security.AccessController.checkPermission(AccessController.java:402)
+         *         at java.lang.SecurityManager.checkPermission(SecurityManager.java:516)
+         *         at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1035)
+         *         at java.lang.System.getProperty(System.java:441)
+         *         at sun.security.action.GetPropertyAction.run(GetPropertyAction.java:73)
+         *         at java.security.AccessController.doPrivileged(Native Method)
+         *         at ExceptionInInit$Test.&#60clinit>(ExceptionInInit.java:33)
+         *         at ExceptionInInit.main(ExceptionInInit.java:18)
+         * access: domain that failed ProtectionDomain (file:/tmp/exceptionInInit/<no certificates>)
+         *
+         * The following exception is occurring when this test program tries
+         * to access the test.src property.
+         */
+        private static String test =
+            AccessController.doPrivileged((PrivilegedAction<String>)() -> System.getProperty("test.src", "."));
+
+        Test(String test) {
+            super(test);
+        }
+        public static void showTest() {
+            System.err.println(test);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/vm/jit/JITClassInit.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,75 @@
+/*
+ * 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 4154887
+ * @summary self-parser test causes JDK 1.2 Beta4K segmentation fault
+ * @run main/othervm JITClassInit
+ * @author Tom Rodriguez
+ */
+
+public class JITClassInit {
+    public static void main(String[] args) {
+        Token t = new Token();
+        new TokenTable();
+    }
+
+}
+
+class TokenTable {
+    public TokenTable() {
+        new TokenTypeIterator(this);
+    }
+
+    public void for_token_type(Token t) {
+        t.keyword_character_class();
+    }
+}
+
+class Token {
+    public Object keyword_character_class() {
+        return new Object();
+    }
+}
+
+class NameOrKeywordToken extends Token {
+    static TokenTable kt = new TokenTable();
+    public Object keyword_character_class() {
+        return new Object();
+    }
+}
+
+class CapKeywordToken extends NameOrKeywordToken {
+    public Object keyword_character_class() {
+        return new Object();
+    }
+};
+
+
+class TokenTypeIterator {
+    public TokenTypeIterator(TokenTable c) {
+        c.for_token_type(new CapKeywordToken());
+        c.for_token_type(new NameOrKeywordToken());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/vm/runtime/ExplicitArithmeticCheck.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,70 @@
+/*
+ * 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 4221448
+ * @summary Use explicit check for integer arithmetic exception on win32.
+ */
+
+public class ExplicitArithmeticCheck {
+    public static void main(String argv[]) throws Exception {
+        for (int i = 0; i < 64; i++) {
+          boolean result = false;
+          int n;
+          try {
+              n = 0 / 0;
+          } catch (ArithmeticException e) {
+              result = true;
+          }
+          if (result == false) {
+            throw new Error("Failed to throw correct exception!");
+          }
+          result = false;
+          try {
+              n = 0 % 0;
+          } catch (ArithmeticException e) {
+              result = true;
+          }
+          if (result == false) {
+            throw new Error("Failed to throw correct exception!");
+          }
+          try {
+              n = 0x80000000 / -1;
+          } catch (Throwable t) {
+            throw new Error("Failed to throw correct exception!");
+          }
+          if (n != 0x80000000) {
+            throw new Error("Incorrect integer arithmetic ! ");
+          }
+          try {
+              n = 0x80000000 % -1;
+          } catch (Throwable t) {
+            throw new Error("Failed to throw correct exception!");
+          }
+          if (n != 0) {
+            throw new Error("Incorrect integer arithmetic!");
+          }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/vm/runtime/MonitorCacheMaybeExpand_DeadLock.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,186 @@
+/*
+ * 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 4087516
+ * @summary Incorrect locking leads to deadlock in monitorCacheMaybeExpand.
+ * @author Anand Palaniswamy
+ * @build MonitorCacheMaybeExpand_DeadLock
+ * @run main/othervm MonitorCacheMaybeExpand_DeadLock
+ */
+
+/**
+ * Background on the bug:
+ *
+ *     The thread local monitor cache had a locking bug (till
+ *     1.2beta1) where two threads trying to expand the monitor cache
+ *     at the same time would cause deadlock. The code paths that the
+ *     two threads must be executing for this to happen is described
+ *     in the bug report.
+ *
+ * Caveat and red-flag:
+ *
+ *     Since deadlocks are very timing dependent, there is a good
+ *     chance this test case will not catch the bug most of the time
+ *     -- on your machine and setting, it is _possible_ that the two
+ *     threads might not try a monitorCacheExpand at the same
+ *     time. But in practice, on Solaris native threads, this program
+ *     deadlocks the VM in about 2 seconds pretty consistently,
+ *     whether MP or not.
+ *
+ *     The rationale for running this test despite this rather large
+ *     caveat is that at worst, it can do no harm.
+ *
+ * The idea:
+ *
+ *     Is to create two monitor hungry threads.
+ *
+ *     Originally Tom Rodriguez and I suspected that this weird state
+ *     of two threads trying to expand monitor cache can happen only
+ *     if:
+ *
+ *         Thread 1: Is in the middle of a monitorCacheMaybeExpand.
+ *         Thread 2: Runs GC and tries to freeClasses(). This causes
+ *                   sysFree() to be invoked, which in turn needs a
+ *                   mutex_lock -- and oops, we end up deadlocking
+ *                   with 1 on green_threads.
+ *
+ *     Which is why this test tries to cause class GC at regular
+ *     intervals.
+ *
+ *     Turns out that the GC is not required. Two instances of the
+ *     monitor hungry threads deadlock the VM pretty quick. :-) Infact
+ *     the static initializer in the forName'd classes running
+ *     alongside one of the hungry threads is sufficient to
+ *     deadlock. Still keep the GC stuff just-in-case (and also
+ *     because I wrote it :-).
+ *
+ */
+public class MonitorCacheMaybeExpand_DeadLock {
+
+    /**
+     * A monitor-hungry thread.
+     */
+    static class LotsaMonitors extends Thread {
+
+        /** How many recursions? Could cause Java stack overflow. */
+        static final int MAX_DEPTH = 800;
+
+        /** What is our depth? */
+        int depth = 0;
+
+        /** Thread ID */
+        int tid;
+
+        /** So output will have thread number. */
+        public LotsaMonitors(int tid, int depth) {
+            super("LotsaMonitors #" + new Integer(tid).toString());
+            this.tid = tid;
+            this.depth = depth;
+        }
+
+        /** Start a recursion that grabs monitors. */
+        public void run() {
+            System.out.println(">>>Starting " + this.toString() + " ...");
+            Thread.currentThread().yield();
+            this.recurse();
+            System.out.println("<<<Finished " + this.toString());
+        }
+
+        /** Every call to this method grabs an extra monitor. */
+        synchronized void recurse() {
+            if (this.depth > 0) {
+                new LotsaMonitors(tid, depth-1).recurse();
+            }
+        }
+    }
+
+    /**
+     * The test.
+     */
+    public static void main(String[] args) {
+        /* Start the two of these crazy threads. */
+        new LotsaMonitors(1, LotsaMonitors.MAX_DEPTH).start();
+        new LotsaMonitors(2, LotsaMonitors.MAX_DEPTH).start();
+
+        /* And sit there and GC for good measure. */
+        for (int i = 0; i < MAX_GC_ITERATIONS; i++) {
+            new LotsaMonitors(i+3, LotsaMonitors.MAX_DEPTH).start();
+            System.out.println(">>>Loading 10 classes and gc'ing ...");
+            Class[] classes = new Class[10];
+            fillClasses(classes);
+            classes = null;
+            System.gc();
+            Thread.currentThread().yield();
+            System.out.println("<<<Finished loading 10 classes and gc'ing");
+        }
+    }
+
+    /** How many times to GC? */
+    static final int MAX_GC_ITERATIONS = 10;
+
+    /** Load some classes into the array. */
+    static void fillClasses(Class[] classes) {
+        for (int i = 0; i < classes.length; i++) {
+            try {
+                classes[i] = Class.forName(classnames[i]);
+            } catch (ClassNotFoundException cnfe) {
+                cnfe.printStackTrace();
+            }
+        }
+    }
+
+    /** Some random classes to load. */
+    private static String[] classnames = {
+        "java.text.DecimalFormat",
+        "java.text.MessageFormat",
+        "java.util.GregorianCalendar",
+        "java.util.ResourceBundle",
+        "java.text.Collator",
+        "java.util.Date",
+        "java.io.Reader",
+        "java.io.Writer",
+        "java.lang.IllegalAccessException",
+        "java.lang.InstantiationException",
+        "java.lang.ClassNotFoundException",
+        "java.lang.CloneNotSupportedException",
+        "java.lang.InterruptedException",
+        "java.lang.NoSuchFieldException",
+        "java.lang.NoSuchMethodException",
+        "java.lang.RuntimeException",
+        "java.lang.ArithmeticException",
+        "java.lang.ArrayStoreException",
+        "java.lang.ClassCastException",
+        "java.lang.StringIndexOutOfBoundsException",
+        "java.lang.NegativeArraySizeException",
+        "java.lang.IllegalStateException",
+        "java.lang.IllegalArgumentException",
+        "java.lang.NumberFormatException",
+        "java.lang.IllegalThreadStateException",
+        "java.lang.IllegalMonitorStateException",
+        "java.lang.SecurityException",
+        "java.lang.ExceptionInInitializerError"
+    };
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/vm/runtime/ReflectStackOverflow.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,67 @@
+/*
+ * 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 4185411
+ * @summary This program crashes in 1.1, but runs okay in 1.2.
+ * @run main/othervm -Xss512k ReflectStackOverflow
+ */
+import java.lang.reflect.*;
+
+public class ReflectStackOverflow {
+    private static final int COUNT = 11000;
+
+    public static void main(String[] cmdline) throws Throwable {
+        for (int i = 0; i < COUNT+1; i++) {
+            stuff(i);
+        }
+    }
+
+    private static void stuff(int count) throws Throwable {
+        if (count < COUNT)
+            return;  // don't do anything the first COUNT times.
+
+        try {
+            final Method method =
+                Method.class.getMethod
+                ("invoke", new Class[] { Object.class, Object[].class });
+
+            final Object[] args = new Object[] { method, null };
+            args[1] = args;
+
+            method.invoke(method, args); // "recursive reflection"
+            // exception should have been thrown by now...
+            System.out.println("how did I get here?");
+        } catch(Throwable t) {
+            int layers;
+            for(layers = 0; t instanceof InvocationTargetException; layers++)
+                t = ((InvocationTargetException)t).getTargetException();
+
+            System.err.println("Found " + layers + " layers of wrappers.");
+            if (!(t instanceof StackOverflowError)) {
+                throw t;
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/vm/runtime/ShiftTest.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,65 @@
+/*
+ * 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 4093292
+ * @summary Test for correct code generation by the JIT
+ */
+public class ShiftTest {
+    static final int w = 32;
+
+    private static void doTest(long ct) throws Exception {
+        int S22 = 0xc46cf7c2;
+        int S23 = 0xcfda9162;
+        int S24 = 0xd029aa4c;
+        int S25 = 0x17cf1801;
+        int A = (int)(ct & 0xffffffffL);
+        int B = (int)(ct >>> 32);
+        int x, y;
+        x = B - S25;
+        y = A & (w-1);
+        B = ((x >>> y) | (x << (w-y))) ^ A;
+        x = A - S24;
+        y = B & (w-1);
+        A = ((x >>> y) | (x << (w-y))) ^ B;
+        x = B - S23;
+        y = A & (w-1);
+        B = ((x >>> y) | (x << (w-y))) ^ A;
+        x = A - S22;
+        y = B & (w-1);
+        A = ((x >>> y) | (x << (w-y))) ^ B;
+        String astr = Integer.toHexString(A);
+        String bstr = Integer.toHexString(B);
+        System.err.println("A = " + astr + " B = " + bstr);
+        if ((!astr.equals("dcb38144")) ||
+            (!bstr.equals("1916de73"))) {
+            throw new RuntimeException("Unexpected shift results!");
+        }
+        System.err.println("Test passed");
+    }
+
+    public static void main(String[] args) throws Exception {
+        doTest(0x496def29b74be041L);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/vm/runtime/WideStrictInline.java	Mon Feb 05 11:12:09 2018 +0800
@@ -0,0 +1,127 @@
+/*
+ * 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 4169183
+ * @summary Check for correct inlining by the interpreter (widefp and strictfp).
+ *          The default is widefp.  A strictfp method was getting inlined
+ *          into a widefp method.
+ */
+
+import java.io.PrintStream;
+
+public class WideStrictInline {
+    static PrintStream out;
+    static float halfUlp;
+
+    static {
+        halfUlp = 1;
+        for ( int i = 127 - 24; i > 0; i-- )
+            halfUlp *= 2;
+    }
+
+    public static void main(String argv[]) throws Exception {
+        out = System.err;
+        pr(-1,"halfUlp",halfUlp);
+        WideStrictInline obj = new WideStrictInline();
+        for( int i=0; i<48; i++ )
+            obj.instanceMethod( i );
+    }
+
+    private static void pr(int i, String desc, float r) {
+        out.print(" i=("+i+") "+desc+" ; == "+r);
+        out.println(" , 0x"+Integer.toHexString(Float.floatToIntBits(r)));
+    }
+
+    private static strictfp float WideStrictInline(float par) {
+        return par;
+    }
+
+    public static strictfp float strictValue(int i) {
+        float r;
+        switch (i%4) {
+        case 0: r = -Float.MAX_VALUE;  break;
+        case 1: r =  Float.MAX_VALUE;  break;
+        case 2: r =  Float.MIN_VALUE;  break;
+        default : r = 1L << 24;
+        }
+        return r;
+    }
+
+    void instanceMethod (int i) throws Exception {
+        float r;
+        switch (i%4) {
+        case 0:
+            if (!Float.isInfinite( WideStrictInline(strictValue(i)*2) +
+                                   Float.MAX_VALUE ))
+                {
+                    pr(i,
+                       "WideStrictInline(-Float.MAX_VALUE * 2) " +
+                       "!= Float.NEGATIVE_INFINITY"
+                       ,WideStrictInline(strictValue(i)*2) + Float.MAX_VALUE);
+                }
+            r = WideStrictInline(strictValue(i)*2) + Float.MAX_VALUE;
+            if ( !Float.isInfinite( r ) ) {
+                pr(i,"r != Float.NEGATIVE_INFINITY",r);
+                throw new RuntimeException();
+            }
+            break;
+        case 1:
+            if (!Float.isInfinite(WideStrictInline(strictValue(i)+halfUlp) -
+                                  Float.MAX_VALUE )) {
+                pr(i,"WideStrictInline(Float.MAX_VALUE+halfUlp) " +
+                   "!= Float.POSITIVE_INFINITY"
+                   ,WideStrictInline(strictValue(i)+halfUlp) - Float.MAX_VALUE);
+            }
+            r = WideStrictInline(strictValue(i)+halfUlp) - Float.MAX_VALUE;
+            if ( !Float.isInfinite( r ) ) {
+                pr(i,"r != Float.POSITIVE_INFINITY",r);
+                throw new RuntimeException();
+            }
+            break;
+        case 2:
+            if (WideStrictInline(strictValue(i)/2) != 0) {
+                pr(i,"WideStrictInline(Float.MIN_VALUE/2) != 0",
+                   WideStrictInline(strictValue(i)/2));
+            }
+            r = WideStrictInline(strictValue(i)/2);
+            if ( r != 0 ) {
+                pr(i,"r != 0",r);
+                throw new RuntimeException();
+            }
+            break;
+        default:
+            if (WideStrictInline(strictValue(i)-0.5f) - strictValue(i) != 0) {
+                pr(i,"WideStrictInline(2^24-0.5) != 2^24",
+                   WideStrictInline(strictValue(i)-0.5f));
+            }
+            r = WideStrictInline(strictValue(i)-0.5f);
+            if ( r - strictValue(i) != 0 ) {
+                pr(i,"r != 2^24",r);
+                throw new RuntimeException();
+            }
+        }
+    }
+
+}