|
| 1 | +/* |
| 2 | + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | + * |
| 5 | + * This code is free software; you can redistribute it and/or modify it |
| 6 | + * under the terms of the GNU General Public License version 2 only, as |
| 7 | + * published by the Free Software Foundation. |
| 8 | + * |
| 9 | + * This code is distributed in the hope that it will be useful, but WITHOUT |
| 10 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | + * version 2 for more details (a copy is included in the LICENSE file that |
| 13 | + * accompanied this code). |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU General Public License version |
| 16 | + * 2 along with this work; if not, write to the Free Software Foundation, |
| 17 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | + * |
| 19 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 20 | + * or visit www.oracle.com if you need additional information or have any |
| 21 | + * questions. |
| 22 | + */ |
| 23 | + |
| 24 | +/* |
| 25 | + * @test |
| 26 | + * @bug 8237950 |
| 27 | + * @summary Test very long chain of StringBuilder append calls. |
| 28 | + * @run main/othervm -Xbatch compiler.stringopts.TestLongStringConcat |
| 29 | + */ |
| 30 | + |
| 31 | +package compiler.stringopts; |
| 32 | + |
| 33 | +public class TestLongStringConcat { |
| 34 | + |
| 35 | + public static String test() { |
| 36 | + return (new StringBuilder("")).append("1").append("2").append("3").append("4"). |
| 37 | + append("5").append("6").append("7").append("8").append("9").append("10"). |
| 38 | + append("11").append("12").append("13").append("14").append("15").append("16"). |
| 39 | + append("17").append("18").append("19").append("20").append("21").append("22"). |
| 40 | + append("23").append("24").append("25").append("26").append("27").append("28"). |
| 41 | + append("29").append("30").append("31").append("32").append("33").append("34"). |
| 42 | + append("35").append("36").append("37").append("38").append("39").append("40"). |
| 43 | + append("41").append("42").append("43").append("44").append("45").append("46"). |
| 44 | + append("47").append("48").append("49").append("50").append("51").append("52"). |
| 45 | + append("53").append("54").append("55").append("56").append("57").append("58"). |
| 46 | + append("59").append("60").append("61").append("62").append("63").append("64"). |
| 47 | + append("65").append("66").append("67").append("68").append("69").append("70"). |
| 48 | + append("71").append("72").append("73").append("74").append("75").append("76"). |
| 49 | + append("77").append("78").append("79").append("80").append("81").append("82"). |
| 50 | + append("83").append("84").append("85").append("86").append("87").append("88"). |
| 51 | + append("89").append("90").append("91").append("92").append("93").append("94"). |
| 52 | + append("95").append("96").append("97").append("98").append("99").append("100"). |
| 53 | + append("101").append("102").append("103").append("104").append("105"). |
| 54 | + append("106").append("107").append("108").append("109").append("110"). |
| 55 | + append("111").append("112").append("113").append("114").append("115"). |
| 56 | + append("116").append("117").append("118").append("119").append("120"). |
| 57 | + append("121").append("122").append("123").append("124").append("125"). |
| 58 | + append("126").append("127").append("128").append("129").append("130"). |
| 59 | + append("131").append("132").append("133").append("134").append("135"). |
| 60 | + append("136").append("137").append("138").append("139").append("140"). |
| 61 | + append("141").append("142").append("143").append("144").append("145"). |
| 62 | + append("146").append("147").append("148").append("149").append("150"). |
| 63 | + append("151").append("152").append("153").append("154").append("155"). |
| 64 | + append("156").append("157").append("158").append("159").append("160"). |
| 65 | + append("161").append("162").append("163").append("164").append("165"). |
| 66 | + append("166").append("167").append("168").append("169").append("170"). |
| 67 | + append("171").append("172").append("173").append("174").append("175"). |
| 68 | + append("176").append("177").append("178").append("179").append("180"). |
| 69 | + append("181").append("182").append("183").append("184").append("185"). |
| 70 | + append("186").append("187").append("188").append("189").append("190"). |
| 71 | + append("191").append("192").append("193").append("194").append("195"). |
| 72 | + append("196").append("197").append("198").append("199").append("200"). |
| 73 | + toString(); |
| 74 | + } |
| 75 | + |
| 76 | + public static void main(String[] args) { |
| 77 | + for (int i = 0; i < 100_000; ++i) { |
| 78 | + test(); |
| 79 | + } |
| 80 | + } |
| 81 | +} |
0 commit comments