test/nashorn/script/nosecurity/JDK-8165198.js
author hannesw
Thu, 21 Dec 2017 10:26:03 +0100
changeset 48407 fcb5b835bf32
parent 47437 54a2f246edd8
permissions -rw-r--r--
8193491: JavaImporter fails to resolve method elements within functions, that contain too many statements Reviewed-by: hannesw, sundar, jlaskey Contributed-by: priya.lakshmi.muthuswamy@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47437
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
     1
/*
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
     4
 *
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
     7
 * published by the Free Software Foundation.
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
     8
 *
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    13
 * accompanied this code).
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    14
 *
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    18
 *
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    21
 * questions.
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    22
 */
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    23
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    24
/**
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    25
 * JDK-8165198:  Inconsistent values with JavaImporter after accessing undefined variable
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    26
 *
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    27
 * @test
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    28
 * @run
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    29
 */
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    30
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    31
var NashornScriptEngineFactory = Java.type("jdk.nashorn.api.scripting.NashornScriptEngineFactory");
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    32
var e = new NashornScriptEngineFactory().getScriptEngine("-ot=false");
48407
fcb5b835bf32 8193491: JavaImporter fails to resolve method elements within functions, that contain too many statements
hannesw
parents: 47437
diff changeset
    33
try {
fcb5b835bf32 8193491: JavaImporter fails to resolve method elements within functions, that contain too many statements
hannesw
parents: 47437
diff changeset
    34
    e.eval("with(new JavaImporter(java.util)){x}");
fcb5b835bf32 8193491: JavaImporter fails to resolve method elements within functions, that contain too many statements
hannesw
parents: 47437
diff changeset
    35
} catch (e) {
fcb5b835bf32 8193491: JavaImporter fails to resolve method elements within functions, that contain too many statements
hannesw
parents: 47437
diff changeset
    36
    print(e);
fcb5b835bf32 8193491: JavaImporter fails to resolve method elements within functions, that contain too many statements
hannesw
parents: 47437
diff changeset
    37
}
47437
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    38
e.eval("with(new JavaImporter(java.util)){x=1}");
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    39
var output2 = e.eval("with(new JavaImporter(java.util)){x}");
54a2f246edd8 8165198: Inconsistent values with JavaImporter after accessing undefined variable
hannesw
parents:
diff changeset
    40
print(output2);