author | attila |
Thu, 31 Jan 2013 18:34:42 +0100 | |
changeset 16206 | 83069fa0935b |
child 24778 | 2ff5d7041566 |
permissions | -rw-r--r-- |
16206
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
1 |
/* |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
2 |
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
4 |
* |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
8 |
* |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
13 |
* accompanied this code). |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
14 |
* |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
18 |
* |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
21 |
* questions. |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
22 |
*/ |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
23 |
|
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
24 |
/** |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
25 |
* JDK-8006529 : Constructor functions that don't need callees must not get |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
26 |
* linked with a MethodHandle boud to a specific function instance. |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
27 |
* @test |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
28 |
* @run |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
29 |
*/ |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
30 |
|
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
31 |
Object.defineProperty(Object.prototype, "extends", { |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
32 |
value: function (superConstructor) { |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
33 |
function ProtoBridge() { } |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
34 |
ProtoBridge.prototype = superConstructor.prototype; |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
35 |
this.prototype = new ProtoBridge(); |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
36 |
this.superConstructor = superConstructor; |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
37 |
} |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
38 |
}); |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
39 |
|
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
40 |
function A() { |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
41 |
} |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
42 |
A.prototype.f = function () { |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
43 |
this.g(); |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
44 |
} |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
45 |
|
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
46 |
function B() { |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
47 |
B.superConstructor.call(this); |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
48 |
this.f(); |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
49 |
} |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
50 |
B.extends(A); |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
51 |
|
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
52 |
B.prototype.g = function () { |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
53 |
print("It worked!") |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
54 |
} |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
55 |
|
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
56 |
function C() { |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
57 |
C.superConstructor.call(this); |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
58 |
} |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
59 |
C.extends(B); |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
60 |
|
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
61 |
var x = [B, C] |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
62 |
for(var i in x) { |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
63 |
print("Doing " + i) |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
64 |
new x[i]() |
83069fa0935b
8006529: Methods always get callee - it should be conditional
attila
parents:
diff
changeset
|
65 |
} |