sundar@1351: /* sundar@1482: * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. sundar@1351: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. sundar@1482: * sundar@1351: * This code is free software; you can redistribute it and/or modify it sundar@1351: * under the terms of the GNU General Public License version 2 only, as sundar@1351: * published by the Free Software Foundation. sundar@1482: * sundar@1351: * This code is distributed in the hope that it will be useful, but WITHOUT sundar@1351: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or sundar@1351: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License sundar@1351: * version 2 for more details (a copy is included in the LICENSE file that sundar@1351: * accompanied this code). sundar@1482: * sundar@1351: * You should have received a copy of the GNU General Public License version sundar@1351: * 2 along with this work; if not, write to the Free Software Foundation, sundar@1351: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. sundar@1482: * sundar@1351: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA sundar@1351: * or visit www.oracle.com if you need additional information or have any sundar@1351: * questions. sundar@1351: */ sundar@1351: sundar@1351: /** sundar@1351: * JDK-8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object sundar@1351: * sundar@1351: * @test sundar@1351: * @run sundar@1351: */ sundar@1351: sundar@1351: function func(arg) { sundar@1351: (function() { print(eval('this')); }).call(arg); sundar@1351: } sundar@1351: sundar@1351: // primitives sundar@1351: func(undefined); sundar@1351: func(null); sundar@1351: func(34.23); sundar@1351: func("hello"); sundar@1351: func(false); sundar@1351: sundar@1351: // script objects sundar@1351: func(this); sundar@1351: func({}); sundar@1351: func({ toString: function() { return "foo" } }); sundar@1351: sundar@1351: // java objects sundar@1351: func(new java.util.Vector()); sundar@1351: var m = new java.util.HashMap(); sundar@1351: m.put("foo", "bar"); sundar@1351: func(m);