Mon, 07 Dec 2015 13:15:47 -0800
Merge
hannesw@1557 | 1 | /* |
hannesw@1557 | 2 | * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
hannesw@1557 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
hannesw@1557 | 4 | * |
hannesw@1557 | 5 | * This code is free software; you can redistribute it and/or modify it |
hannesw@1557 | 6 | * under the terms of the GNU General Public License version 2 only, as |
hannesw@1557 | 7 | * published by the Free Software Foundation. |
hannesw@1557 | 8 | * |
hannesw@1557 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
hannesw@1557 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
hannesw@1557 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
hannesw@1557 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
hannesw@1557 | 13 | * accompanied this code). |
hannesw@1557 | 14 | * |
hannesw@1557 | 15 | * You should have received a copy of the GNU General Public License version |
hannesw@1557 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
hannesw@1557 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
hannesw@1557 | 18 | * |
hannesw@1557 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
hannesw@1557 | 20 | * or visit www.oracle.com if you need additional information or have any |
hannesw@1557 | 21 | * questions. |
hannesw@1557 | 22 | */ |
hannesw@1557 | 23 | |
hannesw@1557 | 24 | /** |
hannesw@1557 | 25 | * JDK-8137281: OutOfMemoryError with large numeric keys in JSON.parse |
hannesw@1557 | 26 | * |
hannesw@1557 | 27 | * @test |
hannesw@1557 | 28 | * @run |
hannesw@1557 | 29 | */ |
hannesw@1557 | 30 | |
hannesw@1557 | 31 | function createObject(startKey, level1, level2) { |
hannesw@1557 | 32 | var root = {}; |
hannesw@1557 | 33 | var key = startKey; |
hannesw@1557 | 34 | for (var i = 0; i < level1; i++) { |
hannesw@1557 | 35 | var child = {}; |
hannesw@1557 | 36 | for (var j = 0; j < level2; j++) { |
hannesw@1557 | 37 | child[key++] = {}; |
hannesw@1557 | 38 | } |
hannesw@1557 | 39 | root[key++] = child; |
hannesw@1557 | 40 | } |
hannesw@1557 | 41 | return root; |
hannesw@1557 | 42 | } |
hannesw@1557 | 43 | |
hannesw@1557 | 44 | JSON.parse(JSON.stringify(createObject(500000, 20, 20))); |
hannesw@1557 | 45 | JSON.parse(JSON.stringify(createObject(1000000, 20, 20))); |
hannesw@1557 | 46 | JSON.parse(JSON.stringify(createObject(2000000, 20, 20))); |
hannesw@1557 | 47 | JSON.parse(JSON.stringify(createObject(4000000, 20, 20))); |
hannesw@1557 | 48 | JSON.parse(JSON.stringify(createObject(8000000, 20, 20))); |
hannesw@1557 | 49 | JSON.parse(JSON.stringify(createObject(16000000, 20, 20))); |