nashorn/test/script/basic/JDK-8007132.js
author twisti
Wed, 11 Nov 2015 14:40:38 -1000
changeset 34173 01bb07d23a5b
parent 16202 f6665e456589
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:
16202
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
     1
/*
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
     2
 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
     4
 *
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
     7
 * published by the Free Software Foundation.
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
     8
 *
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    13
 * accompanied this code).
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    14
 *
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    18
 *
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    21
 * questions.
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    22
 */
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    23
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    24
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    25
/**
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    26
 * JDK-8007232: Java objects returned from constructor functions are lost
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    27
 *
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    28
 * @test
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    29
 * @run
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    30
 */
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    31
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    32
function Func() {
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    33
    return new java.util.HashMap();
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    34
}
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    35
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    36
var f = new Func();
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    37
if (! (f instanceof java.util.Map)) {
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    38
    fail("instance of java.util.Map expected")
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    39
}
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    40
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    41
function check(obj) {
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    42
    if (typeof obj != 'object') {
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    43
        fail("expected 'object' but got " + (typeof obj));
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    44
    }
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    45
}
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    46
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    47
// check primitive returning constructors
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    48
check(new (function() { return 22; }));
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    49
check(new (function() { return false }));
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    50
check(new (function() { return "hello" }));
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    51
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    52
// check null and undefined returning constructors
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    53
check(new (function() { return null; }));
f6665e456589 8007132: Java objects returned from constructor functions are lost
sundar
parents:
diff changeset
    54
check(new (function() { return undefined; }));