author | amurillo |
Wed, 14 Sep 2016 11:22:39 -0700 | |
changeset 40970 | 2ea624c0ae04 |
parent 40824 | c24d212a8733 |
permissions | -rw-r--r-- |
40824
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
1 |
/* |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
4 |
* |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
8 |
* |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
13 |
* accompanied this code). |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
14 |
* |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
18 |
* |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
21 |
* questions. |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
22 |
*/ |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
23 |
|
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
24 |
/** |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
25 |
* JDK-8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
26 |
* |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
27 |
* @test |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
28 |
* @run |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
29 |
*/ |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
30 |
|
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
31 |
var o = {}; |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
32 |
|
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
33 |
function invoke() { |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
34 |
return o._(); |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
35 |
} |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
36 |
|
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
37 |
Object.prototype.__noSuchProperty__ = function() { |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
38 |
return function() { return "no such property" }; |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
39 |
}; |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
40 |
|
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
41 |
Assert.assertEquals(invoke(), "no such property"); |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
42 |
|
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
43 |
Object.prototype.__noSuchMethod__ = function() { |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
44 |
return "no such method"; |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
45 |
}; |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
46 |
|
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
47 |
Assert.assertEquals(invoke(), "no such method"); |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
48 |
|
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
49 |
Object.prototype._ = function() { |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
50 |
return "underscore method"; |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
51 |
}; |
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
52 |
|
c24d212a8733
8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded
hannesw
parents:
diff
changeset
|
53 |
Assert.assertEquals(invoke(), "underscore method"); |