test/script/basic/NASHORN-837.js

Tue, 08 Jan 2013 10:52:11 +0100

author
lagergren
date
Tue, 08 Jan 2013 10:52:11 +0100
changeset 13
d8e4d66f1a06
child 144
4be452026847
permissions
-rw-r--r--

8005843: refSymbols lookup of unbound variable could cause NullPointerException in Lower
Reviewed-by: hannesw, attila

lagergren@13 1 /*
lagergren@13 2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
lagergren@13 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
lagergren@13 4 *
lagergren@13 5 * This code is free software; you can redistribute it and/or modify it
lagergren@13 6 * under the terms of the GNU General Public License version 2 only, as
lagergren@13 7 * published by the Free Software Foundation.
lagergren@13 8 *
lagergren@13 9 * This code is distributed in the hope that it will be useful, but WITHOUT
lagergren@13 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
lagergren@13 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
lagergren@13 12 * version 2 for more details (a copy is included in the LICENSE file that
lagergren@13 13 * accompanied this code).
lagergren@13 14 *
lagergren@13 15 * You should have received a copy of the GNU General Public License version
lagergren@13 16 * 2 along with this work; if not, write to the Free Software Foundation,
lagergren@13 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
lagergren@13 18 *
lagergren@13 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
lagergren@13 20 * or visit www.oracle.com if you need additional information or have any
lagergren@13 21 * questions.
lagergren@13 22 */
lagergren@13 23
lagergren@13 24 /**
lagergren@13 25 * NASHORN-837 : refSymbol lookup caused nullpointer exception in Lower
lagergren@13 26 *
lagergren@13 27 * @test
lagergren@13 28 * @run
lagergren@13 29 */
lagergren@13 30
lagergren@13 31 var failed = false;
lagergren@13 32
lagergren@13 33 try {
lagergren@13 34 try {
lagergren@13 35 throw new TypeError('error');
lagergren@13 36 } catch (iox) {
lagergren@13 37 function f() {
lagergren@13 38 print(iox.message);
lagergren@13 39 }
lagergren@13 40 }
lagergren@13 41 f();
lagergren@13 42 } catch (e) {
lagergren@13 43 failed = (e instanceof ReferenceError);
lagergren@13 44 //iox not defined should be thrown
lagergren@13 45 }
lagergren@13 46
lagergren@13 47 if (!failed) {
lagergren@13 48 print("Failure! iox did not throw correct exception");
lagergren@13 49 }
lagergren@13 50

mercurial