nashorn/test/script/basic/JDK-8006424.js
author sundar
Wed, 16 Jan 2013 21:26:55 +0530
changeset 16178 2704dd3b2691
child 16204 c53eef0eb729
permissions -rw-r--r--
8006424: Passing null or undefined to adapter class constructors results in NPE or ClassCastException Reviewed-by: attila, hannesw, jlaskey

/**
 * JDK-8006424 : Passing null or undefined to adapter class constructors results in NPE or ClassCastException
 *
 * @test
 * @run
 */

function check(callback) {
    try {
        callback();
        fail("should have thrown exception");
    } catch (e) {
        if (! (e instanceof TypeError)) {
            fail("TypeError expected, but got " + e);
        }
    }
}

check(function() { new java.lang.ClassLoader(null) });
check(function() { new java.lang.ClassLoader(undefined) });
check(function() { new java.lang.Runnable(null) });
check(function() { new java.lang.Runnable(undefined) });