author | sundar |
Wed, 06 May 2015 20:04:42 +0530 | |
changeset 30394 | 72a59e4dffea |
parent 28441 | beb75d5da248 |
child 31925 | 85c87bc2f1f3 |
permissions | -rw-r--r-- |
28441
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
1 |
/* |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
2 |
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
4 |
* |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
8 |
* |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
13 |
* accompanied this code). |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
14 |
* |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
18 |
* |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
21 |
* questions. |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
22 |
*/ |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
23 |
|
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
24 |
/** |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
25 |
* JDK-8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
26 |
* |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
27 |
* @test |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
28 |
* @run |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
29 |
*/ |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
30 |
|
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
31 |
function func(arg) { |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
32 |
(function() { print(eval('this')); }).call(arg); |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
33 |
} |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
34 |
|
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
35 |
// primitives |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
36 |
func(undefined); |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
37 |
func(null); |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
38 |
func(34.23); |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
39 |
func("hello"); |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
40 |
func(false); |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
41 |
|
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
42 |
// script objects |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
43 |
func(this); |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
44 |
func({}); |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
45 |
func({ toString: function() { return "foo" } }); |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
46 |
|
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
47 |
// java objects |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
48 |
func(new java.util.Vector()); |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
49 |
var m = new java.util.HashMap(); |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
50 |
m.put("foo", "bar"); |
beb75d5da248
8068985: Wrong 'this' bound to eval call within a function when caller's 'this' is a Java object
sundar
parents:
diff
changeset
|
51 |
func(m); |