author | hannesw |
Mon, 23 Apr 2018 17:45:05 +0200 | |
changeset 49855 | 3739e9a5b6b5 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
29411
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
1 |
/* |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
4 |
* |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
8 |
* |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
13 |
* accompanied this code). |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
14 |
* |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
18 |
* |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
21 |
* questions. |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
22 |
*/ |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
23 |
|
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
24 |
/** |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
25 |
* JDK-8074693: Different instances of same function use same allocator map |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
26 |
* |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
27 |
* @test |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
28 |
* @run |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
29 |
*/ |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
30 |
|
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
31 |
var lib = {}; |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
32 |
|
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
33 |
lib.mixin = function(target, source) { |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
34 |
for (var p in source) { |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
35 |
if (source.hasOwnProperty(p) && !target.hasOwnProperty(p)) { |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
36 |
target.prototype[p] = source[p]; |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
37 |
} |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
38 |
} |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
39 |
}; |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
40 |
|
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
41 |
lib.declare = function(def) { |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
42 |
var className = def.name; |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
43 |
|
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
44 |
lib[className] = function() { |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
45 |
this.init.apply(this, arguments); |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
46 |
}; |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
47 |
|
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
48 |
lib.mixin(lib[className], def.members); |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
49 |
}; |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
50 |
|
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
51 |
|
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
52 |
lib.declare({ |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
53 |
name: "ClassA", |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
54 |
members: { |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
55 |
init : function () { |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
56 |
print("init A called"); |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
57 |
} |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
58 |
} |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
59 |
}); |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
60 |
|
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
61 |
lib.declare({ |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
62 |
name: "ClassB", |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
63 |
members: { |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
64 |
util : function () { |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
65 |
print("util called") |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
66 |
}, |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
67 |
init : function() { |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
68 |
print("init B called"); |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
69 |
} |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
70 |
} |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
71 |
}); |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
72 |
|
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
73 |
var objA = new lib.ClassA(); |
79e9da5fffbc
8074693: Different instances of same function use same allocator map
hannesw
parents:
diff
changeset
|
74 |
var objB = new lib.ClassB(); |