Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/lang/String/concat/CompactStringsInitialCoder.java
41153 views
1
/*
2
* Copyright (c) 2016, 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
* @summary StringConcatFactory MH_INLINE_SIZED_EXACT strategy does not work with -XX:-CompactStrings
27
* @bug 8148869
28
*
29
* @compile -XDstringConcat=indy CompactStringsInitialCoder.java
30
* @run main/othervm -Xverify:all -XX:+CompactStrings CompactStringsInitialCoder
31
*
32
* @compile -XDstringConcat=indyWithConstants CompactStringsInitialCoder.java
33
* @run main/othervm -Xverify:all -XX:+CompactStrings CompactStringsInitialCoder
34
*
35
* @compile -XDstringConcat=indy CompactStringsInitialCoder.java
36
* @run main/othervm -Xverify:all -XX:-CompactStrings CompactStringsInitialCoder
37
*
38
* @compile -XDstringConcat=indyWithConstants CompactStringsInitialCoder.java
39
* @run main/othervm -Xverify:all -XX:-CompactStrings CompactStringsInitialCoder
40
*/
41
import java.lang.StringBuilder;
42
43
public class CompactStringsInitialCoder {
44
45
static String strEmpty = "";
46
static String strLatin1 = "\u0042";
47
static String strUTF16 = "\u4242";
48
static char charLatin1 = '\u0042';
49
static char charUTF16 = '\u4242';
50
51
public static void main(String[] args) throws Exception {
52
test("\u0042", "" + '\u0042');
53
test("\u4242", "" + '\u4242');
54
55
test("\u0042", "" + charLatin1);
56
test("\u4242", "" + charUTF16);
57
58
test("\u0042", strEmpty + '\u0042');
59
test("\u4242", strEmpty + '\u4242');
60
61
test("\u0042\u0042", strLatin1 + '\u0042');
62
test("\u0042\u4242", strLatin1 + '\u4242');
63
test("\u4242\u0042", strUTF16 + '\u0042');
64
test("\u4242\u4242", strUTF16 + '\u4242');
65
66
test("\u0042\u0042", "\u0042" + charLatin1);
67
test("\u0042\u4242", "\u0042" + charUTF16);
68
test("\u4242\u0042", "\u4242" + charLatin1);
69
test("\u4242\u4242", "\u4242" + charUTF16);
70
71
test("\u0042\u0042", "" + charLatin1 + charLatin1);
72
test("\u0042\u4242", "" + charLatin1 + charUTF16);
73
test("\u4242\u0042", "" + charUTF16 + charLatin1);
74
test("\u4242\u4242", "" + charUTF16 + charUTF16);
75
}
76
77
public static void test(String expected, String actual) {
78
if (!expected.equals(actual)) {
79
StringBuilder sb = new StringBuilder();
80
sb.append("Expected = ");
81
sb.append(expected);
82
sb.append(", actual = ");
83
sb.append(actual);
84
throw new IllegalStateException(sb.toString());
85
}
86
}
87
88
89
}
90
91