comparison test/compiler/stringopts/TestOptimizeStringConcat.java @ 22812:007ed0fcee27

8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat Reviewed-by: kvn
author asiebenborn
date Fri, 16 Jan 2015 13:58:22 +0100
parents
children
comparison
equal deleted inserted replaced
22811:06face256a8c 22812:007ed0fcee27
1 /*
2 * Copyright 2015 SAP AG. 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 8068909
27 * @key regression
28 * @summary test that string optimizations produce code, that doesn't lead to a crash.
29 * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestOptimizeStringConcat
30 * @author axel.siebenborn@sap.com
31 */
32 public class TestOptimizeStringConcat {
33
34 static boolean checkArgumentSyntax(String value, String allowedchars, String notallowedchars, String logmsg) {
35 String rc = null;
36
37 int maxchar = 99999;
38 int minchar = 1;
39 if ((allowedchars != null && notallowedchars != null) || minchar > maxchar) {
40 rc = "internal error";
41 } else {
42 if (value == null) {
43 rc = "the value null is not allowed, it is missing";
44 } else if (value != null && minchar > 0 && value.trim().equals("")) {
45 rc = "the value must not be empty";
46 } else if (value != null) {
47 if (value.length() < minchar || value.length() > maxchar) {
48 if (rc == null) {
49 rc = "the value length must be between +minchar+ and +maxchar";
50 }
51 }
52 char[] _value = value.toCharArray();
53 boolean dotfound = false;
54 int i = 1;
55 if (_value[i] == '.' && !dotfound) {
56 dotfound = true;
57 } else if (allowedchars != null && allowedchars.indexOf(_value[i]) == -1) {
58 if (rc == null) {
59 rc = "the value contains an illegal character: '" + _value[i] + "', only following characters are allowed: '+allowedchars+'";
60 } else {
61 rc += " / the value contains an illegal character: '" + _value[i] + "', only following characters are allowed: '+allowedchars+'";
62 }
63 } else if (notallowedchars != null && notallowedchars.indexOf(_value[i]) != -1) {
64 if (rc == null) {
65 rc = "the value contains an illegal character: '" + _value[i] + "', following characters are not allowed '+notallowedchars+'";
66 } else {
67 rc += " / the value contains an illegal character: '" + _value[i] + "', following characters are not allowed '+notallowedchars+'";
68 }
69 }
70 }
71 }
72
73 if (rc != null) {
74 System.out.println(logmsg + " ==> " + rc);
75 return false;
76 }
77 return true;
78 }
79
80 public static void main(String[] args) {
81 boolean failed = false;
82 for (int i = 0; i < 10000; i++) {
83 failed |= !checkArgumentSyntax("theName", null, "\"<&", "Error consistencyCheck: name in component definition");
84 failed |= !checkArgumentSyntax(null, null, "\"<&", "Error consistencyCheck: name in component definition");
85 failed |= !checkArgumentSyntax("42", "0123456789.", null, "Error consistencyCheck: counter in component definition");
86 }
87 System.out.println(failed);
88 }
89 }