1253N/A/*
1472N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
1253N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1253N/A *
1253N/A * This code is free software; you can redistribute it and/or modify it
1253N/A * under the terms of the GNU General Public License version 2 only, as
1253N/A * published by the Free Software Foundation.
1253N/A *
1253N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1253N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1253N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1253N/A * version 2 for more details (a copy is included in the LICENSE file that
1253N/A * accompanied this code).
1253N/A *
1253N/A * You should have received a copy of the GNU General Public License version
1253N/A * 2 along with this work; if not, write to the Free Software Foundation,
1253N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1253N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
1253N/A *
1253N/A */
1253N/A
1253N/A/**
1253N/A * @test
1253N/A * @bug 6910605
1253N/A * @summary C2: NullPointerException/ClassCaseException is thrown when C2 with DeoptimizeALot is used
1253N/A *
1253N/A * @run main/othervm -Xmx64m -XX:+IgnoreUnrecognizedVMOptions -XX:+DeoptimizeALot -XX:+DoEscapeAnalysis -Xbatch -XX:InlineSmallCode=2000 Test
1253N/A *
1253N/A */
1253N/A
1253N/A/*
1253N/A * Added InlineSmallCode=2000 to guaranty inlining of StringBuilder::append() to allow scalar replace StringBuilder object.
1253N/A *
1253N/A * original test: gc/gctests/StringGC
1253N/A */
1253N/A
1253N/Apublic class Test {
1253N/A private final String toAdd = "0123456789abcdef";
1253N/A private int maxLength;
1253N/A private static final int numberOfThreads = 8;
1253N/A
1253N/A private class StringAdder extends Thread {
1253N/A private String s;
1253N/A
1253N/A public void test() {
1253N/A s = s + toAdd;
1253N/A }
1253N/A public void run() {
1253N/A do {
1253N/A test();
1253N/A } while (s.length() < maxLength);
1253N/A }
1253N/A }
1253N/A
1253N/A public void test() throws InterruptedException {
1253N/A maxLength = toAdd.length() * 15000/ numberOfThreads;
1253N/A StringAdder[] sa = new StringAdder[numberOfThreads];
1253N/A for (int i = 0; i < numberOfThreads; i++) {
1253N/A sa[i] = new StringAdder();
1253N/A sa[i].start();
1253N/A }
1253N/A for (int i = 0; i < numberOfThreads; i++) {
1253N/A sa[i].join();
1253N/A }
1253N/A }
1253N/A
1253N/A public static void main(String[] args) throws InterruptedException {
1253N/A Test t = new Test();
1253N/A t.test();
1253N/A }
1253N/A}