nashorn/test/script/basic/JDK-8067136.js
author hannesw
Fri, 03 Feb 2017 13:28:00 +0100
changeset 43555 1bb10bccf057
parent 27973 ecc16e813691
permissions -rw-r--r--
8173888: Test for JDK-8169481 causes stack overflows in parser tests Reviewed-by: jlaskey, sundar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27973
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
     1
/*
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
     4
 *
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
     8
 *
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    13
 * accompanied this code).
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    14
 *
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    18
 *
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    21
 * questions.
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    22
 */
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    23
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    24
/**
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    25
 * JDK-8067136: BrowserJSObjectLinker does not handle call on JSObjects
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    26
 *
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    27
 * @test
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    28
 * @option -scripting
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    29
 * @run
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    30
 */
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    31
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    32
// call on netscape.javascript.JSObject
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    33
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    34
function main() {
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    35
    var JSObject;
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    36
    try {
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    37
        JSObject = Java.type("netscape.javascript.JSObject");
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    38
    } catch (e) {
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    39
        if (e instanceof java.lang.ClassNotFoundException) {
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    40
            // pass vacuously by emitting the .EXPECTED file content
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    41
            var str = readFully(__DIR__ + "JDK-8067136.js.EXPECTED");
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    42
            print(str.substring(0, str.length - 1));
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    43
            return;
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    44
        } else{
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    45
            fail("unexpected exception for JSObject", e);
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    46
        }
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    47
    }
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    48
    test(JSObject);
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    49
}
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    50
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    51
function test(JSObject) {
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    52
    var obj = new (Java.extend(JSObject))() {
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    53
        getMember: function(name) {
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    54
            if (name == "func") {
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    55
                return new (Java.extend(JSObject)) {
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    56
                    call: function(n) {
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    57
                        print("func called");
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    58
                    }
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    59
                }
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    60
            }
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    61
            return name.toUpperCase();
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    62
        },
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    63
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    64
    };
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    65
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    66
    obj.func();
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    67
}
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    68
ecc16e813691 8067136: BrowserJSObjectLinker does not handle call on JSObjects
sundar
parents:
diff changeset
    69
main();