RFR 8072853: SimpleScriptContext used by NashornScriptEngine doesn't completely complies to the spec regarding exception throwing

Paul Sandoz paul.sandoz at oracle.com
Mon May 18 12:07:20 UTC 2015


On May 18, 2015, at 12:44 PM, A. Sundararajan <sundararajan.athijegannathan at oracle.com> wrote:

> Please review http://cr.openjdk.java.net/~sundar/8072853/webrev.00/ for https://bugs.openjdk.java.net/browse/JDK-8072853
> 

Changes to SimpleScriptContext look good.

Test-wise you could reduce the duplication with a method accepting Consumer<ScriptContext>.

e.g.

    @Test
    public void getAttributeEmptyName() {
        test(sc -> sc.getAttribute("", ScriptContext.GLOBAL_SCOPE));
    }

    void test(Consumer<ScriptContext> c) {
        for (ScriptEngineFactory fac : getFactories()) {
            ScriptContext sc = fac.getScriptEngine().getContext();
            String name = fac.getEngineName();
            try {
                c.accept(sc);
                throw new RuntimeException("no exception for " + name);
            } catch (IllegalArgumentException iae) {
                System.out.println("got " + iae + " as expected for " + name);
            }
        }
    }

Paul.



More information about the core-libs-dev mailing list