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