nashorn/test/script/trusted/JDK-8032060.js
author twisti
Wed, 11 Nov 2015 14:40:38 -1000
changeset 34173 01bb07d23a5b
parent 24778 2ff5d7041566
permissions -rw-r--r--
8141133: [JVMCI] crash during safepoint deopt if rethrow_exception is set Reviewed-by: twisti Contributed-by: Gilles Duboscq <gilles.m.duboscq@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22389
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
     1
/*
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 22389
diff changeset
     4
 *
22389
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
     7
 * published by the Free Software Foundation.
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 22389
diff changeset
     8
 *
22389
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    13
 * accompanied this code).
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 22389
diff changeset
    14
 *
22389
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 22389
diff changeset
    18
 *
22389
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    21
 * questions.
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    22
 */
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    23
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    24
/**
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    25
 * JDK-8032060: PropertyMap of Error objects is not stable
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    26
 *
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    27
 * @test
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    28
 * @option -Dnashorn.debug=true
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    29
 * @fork
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    30
 * @run
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    31
 */
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    32
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    33
function checkMap(e1, e2) {
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    34
    if (! Debug.identical(Debug.map(e1), Debug.map(e2))) {
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    35
        fail("e1 and e2 have different maps");
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    36
    }
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    37
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    38
    var m1, m2;
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    39
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    40
    try {
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    41
        throw e1
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    42
    } catch (e) {
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    43
        m1 = Debug.map(e)
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    44
    }
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    45
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    46
    try {
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    47
        throw e2
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    48
    } catch (e) {
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    49
        m2 = Debug.map(e)
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    50
    }
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    51
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    52
    if (! Debug.identical(m1, m2)) {
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    53
        fail("e1 and e2 have different maps after being thrown");
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    54
    }
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    55
}
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    56
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    57
checkMap(new Error(), new Error());
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    58
checkMap(new EvalError(), new EvalError());
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    59
checkMap(new RangeError(), new RangeError());
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    60
checkMap(new ReferenceError(), new ReferenceError());
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    61
checkMap(new SyntaxError(), new SyntaxError());
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    62
checkMap(new TypeError(), new TypeError());
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    63
checkMap(new URIError(), new URIError());
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    64
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    65
// now try with message param
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    66
checkMap(new Error("x"), new Error("y"));
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    67
checkMap(new EvalError("x"), new EvalError("y"));
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    68
checkMap(new RangeError("x"), new RangeError("y"));
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    69
checkMap(new ReferenceError("x"), new ReferenceError("y"));
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    70
checkMap(new SyntaxError("x"), new SyntaxError("y"));
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    71
checkMap(new TypeError("x"), new TypeError("y"));
ea3dda90768c 8032060: PropertyMap of Error objects is not stable
sundar
parents:
diff changeset
    72
checkMap(new URIError("x"), new URIError("y"));