Java Code Examples for jdk.test.lib.Utils#runAndCheckException()

The following examples show how to use jdk.test.lib.Utils#runAndCheckException() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DeoptimizationTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void test() {
    Asserts.assertTrue(WB.isMethodCompiled(testMethod),
            "Method expected to be compiled");
    Asserts.assertEQ(WB.getMethodCompilationLevel(testMethod),
            CompilerWhiteBoxTest.COMP_LEVEL_AOT,
            "Unexpected compilation level at start");
    Utils.runAndCheckException(() -> testMethod(), ArithmeticException.class);
    Asserts.assertFalse(WB.isMethodCompiled(testMethod),
            "Method is unexpectedly compiled after deoptimization");
    Asserts.assertEQ(WB.getMethodCompilationLevel(testMethod), 0,
            "Unexpected compilation level after deoptimization");
}
 
Example 2
Source File: AllocateCompileIdTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void runSanityIncorrectTest(
        Pair<CompileCodeTestCase, Class<? extends Throwable>> testCase) {
    System.out.println(testCase);
    Class<? extends Throwable> exception = testCase.second;
    Executable aMethod = testCase.first.executable;
    int bci = testCase.first.bci;
    HotSpotResolvedJavaMethod method = CTVMUtilities
            .getResolvedMethod(aMethod);
    Utils.runAndCheckException(
            () -> CompilerToVMHelper.allocateCompileId(method, bci),
            exception);
}
 
Example 3
Source File: BlobSanityTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private static void runTest(Consumer<Integer> consumer, int val, String testCaseName, Class<? extends Throwable>
        expectedException) {
        System.out.println("Calling " + testCaseName);
        Utils.runAndCheckException(() -> consumer.accept(val), expectedException);
        System.out.println("Looks ok");
}
 
Example 4
Source File: JvmciNotifyInstallEventTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private void runTest() {
    if (gotInstallNotification != 0) {
        throw new Error("Got install notification before test actions");
    }
    HotSpotCodeCacheProvider codeCache;
    try {
        codeCache = (HotSpotCodeCacheProvider) HotSpotJVMCIRuntime.runtime()
                .getHostJVMCIBackend().getCodeCache();
    } catch (InternalError ie) {
        // passed
        return;
    }
    Method testMethod;
    try {
        testMethod = SimpleClass.class.getDeclaredMethod(METHOD_NAME);
    } catch (NoSuchMethodException e) {
        throw new Error("TEST BUG: Can't find " + METHOD_NAME, e);
    }
    HotSpotResolvedJavaMethod method = CTVMUtilities
            .getResolvedMethod(SimpleClass.class, testMethod);
    HotSpotCompiledCode compiledCode = new HotSpotCompiledCode(METHOD_NAME,
            new byte[0], 0, new Site[0], new Assumption[0],
            new ResolvedJavaMethod[]{method}, new Comment[0], new byte[0],
            16, new DataPatch[0], false, 0, null);
    codeCache.installCode(method, compiledCode, /* installedCode = */ null,
            /* speculationLog = */ null, /* isDefault = */ false);
    Asserts.assertEQ(gotInstallNotification, 1,
            "Got unexpected event count after 1st install attempt");
    // since "empty" compilation result is ok, a second attempt should be ok
    codeCache.installCode(method, compiledCode, /* installedCode = */ null,
            /* speculationLog = */ null, /* isDefault = */ false);
    Asserts.assertEQ(gotInstallNotification, 2,
            "Got unexpected event count after 2nd install attempt");
    // and an incorrect cases
    Utils.runAndCheckException(() -> {
        codeCache.installCode(method, null, null, null, true);
    }, NullPointerException.class);
    Asserts.assertEQ(gotInstallNotification, 2,
            "Got unexpected event count after 3rd install attempt");
    Utils.runAndCheckException(() -> {
        codeCache.installCode(null, null, null, null, true);
    }, NullPointerException.class);
    Asserts.assertEQ(gotInstallNotification, 2,
            "Got unexpected event count after 4th install attempt");
}
 
Example 5
Source File: InvalidateInstalledCodeTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private void checkNull() {
    Utils.runAndCheckException(
            () -> CompilerToVMHelper.invalidateInstalledCode(null),
            NullPointerException.class);
}
 
Example 6
Source File: DisassembleCodeBlobTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private void checkNull() {
    Utils.runAndCheckException(
            () -> CompilerToVMHelper.disassembleCodeBlob(null),
            NullPointerException.class);
}