hannesw@1256: /* hannesw@1256: * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. hannesw@1256: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. hannesw@1256: * hannesw@1256: * This code is free software; you can redistribute it and/or modify it hannesw@1256: * under the terms of the GNU General Public License version 2 only, as hannesw@1256: * published by the Free Software Foundation. hannesw@1256: * hannesw@1256: * This code is distributed in the hope that it will be useful, but WITHOUT hannesw@1256: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or hannesw@1256: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License hannesw@1256: * version 2 for more details (a copy is included in the LICENSE file that hannesw@1256: * accompanied this code). hannesw@1256: * hannesw@1256: * You should have received a copy of the GNU General Public License version hannesw@1256: * 2 along with this work; if not, write to the Free Software Foundation, hannesw@1256: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. hannesw@1256: * hannesw@1256: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA hannesw@1256: * or visit www.oracle.com if you need additional information or have any hannesw@1256: * questions. hannesw@1256: */ hannesw@1256: hannesw@1256: /** hannesw@1256: * JDK-8074693: Different instances of same function use same allocator map hannesw@1256: * hannesw@1256: * @test hannesw@1256: * @run hannesw@1256: */ hannesw@1256: hannesw@1256: var lib = {}; hannesw@1256: hannesw@1256: lib.mixin = function(target, source) { hannesw@1256: for (var p in source) { hannesw@1256: if (source.hasOwnProperty(p) && !target.hasOwnProperty(p)) { hannesw@1256: target.prototype[p] = source[p]; hannesw@1256: } hannesw@1256: } hannesw@1256: }; hannesw@1256: hannesw@1256: lib.declare = function(def) { hannesw@1256: var className = def.name; hannesw@1256: hannesw@1256: lib[className] = function() { hannesw@1256: this.init.apply(this, arguments); hannesw@1256: }; hannesw@1256: hannesw@1256: lib.mixin(lib[className], def.members); hannesw@1256: }; hannesw@1256: hannesw@1256: hannesw@1256: lib.declare({ hannesw@1256: name: "ClassA", hannesw@1256: members: { hannesw@1256: init : function () { hannesw@1256: print("init A called"); hannesw@1256: } hannesw@1256: } hannesw@1256: }); hannesw@1256: hannesw@1256: lib.declare({ hannesw@1256: name: "ClassB", hannesw@1256: members: { hannesw@1256: util : function () { hannesw@1256: print("util called") hannesw@1256: }, hannesw@1256: init : function() { hannesw@1256: print("init B called"); hannesw@1256: } hannesw@1256: } hannesw@1256: }); hannesw@1256: hannesw@1256: var objA = new lib.ClassA(); hannesw@1256: var objB = new lib.ClassB();