author | prr |
Tue, 01 Jul 2014 10:20:56 -0700 | |
changeset 25211 | 2476da7d73bf |
parent 14856 | 92a1bcf46888 |
child 45944 | 882cea808912 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
14856 | 2 |
* Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 22 |
*/ |
23 |
||
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
24 |
/* |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
25 |
* @test |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
26 |
* @bug 5030265 |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
27 |
* @compile -XDignore.symbol.file UnicodeTest.java |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
28 |
* @run main/othervm UnicodeTest |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
29 |
* @summary Verify that the J2RE can handle all legal Unicode characters |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
30 |
* in class names unless limited by the file system encoding |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
31 |
* or the encoding used for command line arguments. |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
32 |
* @author Norbert Lindenberg, ksrini |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
33 |
*/ |
2 | 34 |
|
35 |
/* |
|
36 |
* This class creates Java source files using Unicode characters |
|
37 |
* that test the limits of what's possible |
|
38 |
* - in situations where the platform encoding imposes limits |
|
39 |
* (command line arguments, non-Unicode file system) |
|
40 |
* - in situations where full Unicode is supported |
|
41 |
* (file system access in UTF-8 locales and on Windows 2000++, |
|
42 |
* jar file contents) |
|
43 |
* |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
44 |
* This test needs to be run in othervm as the locale is reset. |
2 | 45 |
*/ |
46 |
||
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
47 |
import java.io.File; |
2 | 48 |
import java.io.FileOutputStream; |
49 |
import java.io.OutputStreamWriter; |
|
50 |
import java.nio.charset.Charset; |
|
51 |
import java.util.Locale; |
|
52 |
||
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
53 |
public class UnicodeTest extends TestHelper { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
54 |
static final File UnicodeTestSrc = new File("UnicodeTest-src"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
55 |
static final File UnicodeTestClasses = new File("UnicodeTest-classes"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
56 |
static final String UnicodeTestJarName = "UnicodeTest" + JAR_FILE_EXT; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
57 |
static final File UnicodeTestJar = new File(UnicodeTestJarName); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
58 |
static final File SolarisUnicodeTestJar = new File(TEST_SOURCES_DIR, |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
59 |
UnicodeTestJarName); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
60 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
61 |
/* |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
62 |
* the main method is a port of the shell based test to a java, this |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
63 |
* eliminates the need for MKS on windows, thus we can rely on consistent |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
64 |
* results regardless of the shell being used. |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
65 |
*/ |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
66 |
public static void main(String... args) throws Exception { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
67 |
System.out.println("creating test source files"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
68 |
UnicodeTestSrc.mkdirs(); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
69 |
UnicodeTestClasses.mkdirs(); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
70 |
String classname = generateSources(); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
71 |
File javaFile = new File(UnicodeTestSrc, classname + JAVA_FILE_EXT); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
72 |
System.out.println("building test apps"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
73 |
compile("-encoding", "UTF-8", |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
74 |
"-sourcepath", UnicodeTestSrc.getAbsolutePath(), |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
75 |
"-d", UnicodeTestClasses.getAbsolutePath(), |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
76 |
javaFile.getAbsolutePath()); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
77 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
78 |
createJar("-cvfm", UnicodeTestJar.getAbsolutePath(), |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
79 |
new File(UnicodeTestSrc, "MANIFEST.MF").getAbsolutePath(), |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
80 |
"-C", UnicodeTestClasses.getAbsolutePath(), "."); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
81 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
82 |
if (!UnicodeTestJar.exists()) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
83 |
throw new Error("failed to create " + UnicodeTestJar.getAbsolutePath()); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
84 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
85 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
86 |
System.out.println("running test app using class file"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
87 |
TestResult tr = doExec(javaCmd, |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
88 |
"-cp", UnicodeTestClasses.getAbsolutePath(), classname); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
89 |
if (!tr.isOK()) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
90 |
System.out.println(tr); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
91 |
throw new RuntimeException("test fails"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
92 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
93 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
94 |
System.out.println("delete generated files with non-ASCII names"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
95 |
recursiveDelete(UnicodeTestSrc); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
96 |
recursiveDelete(UnicodeTestClasses); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
97 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
98 |
/* |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
99 |
* test in whatever the default locale is |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
100 |
*/ |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
101 |
runJarTests(); |
2 | 102 |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
103 |
/* |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
104 |
* if the Japanese locale is available, test in that locale as well |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
105 |
*/ |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
106 |
if (setLocale(Locale.JAPANESE)) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
107 |
runJarTests(); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
108 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
109 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
110 |
/* |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
111 |
* if we can switch to a C locale, then test whether jar files with |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
112 |
* non-ASCII characters in the manifest still work in this crippled |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
113 |
* environment |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
114 |
*/ |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
115 |
if (setLocale(Locale.ENGLISH)) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
116 |
runJarTests(); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
117 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
118 |
// thats it we are outta here |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
119 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
120 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
121 |
static void runJarTests() { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
122 |
System.out.println("running test app using newly built jar file in " + |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
123 |
Locale.getDefault()); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
124 |
runTest(UnicodeTestJar); |
2 | 125 |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
126 |
System.out.println("running test app using jar file " + |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
127 |
"(built with Solaris UTF-8 locale) in " + Locale.getDefault()); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
128 |
runTest(SolarisUnicodeTestJar); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
129 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
130 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
131 |
static void runTest(File testJar) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
132 |
TestResult tr = doExec(javaCmd, "-jar", testJar.getAbsolutePath()); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
133 |
if (!tr.isOK()) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
134 |
System.out.println(tr); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
135 |
throw new RuntimeException("test fails"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
136 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
137 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
138 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
139 |
static boolean setLocale(Locale desired) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
140 |
if (Locale.getDefault().equals(desired)) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
141 |
return true; // already set nothing more |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
142 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
143 |
for (Locale l : Locale.getAvailableLocales()) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
144 |
if (l == desired) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
145 |
Locale.setDefault(l); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
146 |
return true; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
147 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
148 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
149 |
return false; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
150 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
151 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
152 |
static String generateSources() throws Exception { |
2 | 153 |
String commandLineClassNameSuffix = commandLineClassNameSuffix(); |
154 |
String commandLineClassName = "ClassA" + commandLineClassNameSuffix; |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
155 |
String manifestClassName = "ClassB" + |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
156 |
(hasUnicodeFileSystem() ? unicode : commandLineClassNameSuffix); |
2 | 157 |
|
158 |
generateSource(commandLineClassName, manifestClassName); |
|
159 |
generateSource(manifestClassName, commandLineClassName); |
|
160 |
generateManifest(manifestClassName); |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
161 |
return commandLineClassName; |
2 | 162 |
} |
163 |
||
164 |
private static final String defaultEncoding = Charset.defaultCharset().name(); |
|
165 |
||
166 |
// language names taken from java.util.Locale.getDisplayLanguage for the respective language |
|
167 |
private static final String arabic = "\u0627\u0644\u0639\u0631\u0628\u064a\u0629"; |
|
168 |
private static final String s_chinese = "\u4e2d\u6587"; |
|
169 |
private static final String t_chinese = "\u4e2d\u6587"; |
|
170 |
private static final String russian = "\u0440\u0443\u0441\u0441\u043A\u0438\u0439"; |
|
171 |
private static final String hindi = "\u0939\u093f\u0902\u0926\u0940"; |
|
172 |
private static final String greek = "\u03b5\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac"; |
|
173 |
private static final String hebrew = "\u05e2\u05d1\u05e8\u05d9\u05ea"; |
|
174 |
private static final String japanese = "\u65e5\u672c\u8a9e"; |
|
175 |
private static final String korean = "\ud55c\uad6d\uc5b4"; |
|
176 |
private static final String lithuanian = "Lietuvi\u0173"; |
|
177 |
private static final String czech = "\u010de\u0161tina"; |
|
178 |
private static final String turkish = "T\u00fcrk\u00e7e"; |
|
179 |
private static final String spanish = "espa\u00f1ol"; |
|
180 |
private static final String thai = "\u0e44\u0e17\u0e22"; |
|
181 |
private static final String unicode = arabic + s_chinese + t_chinese |
|
182 |
+ russian + hindi + greek + hebrew + japanese + korean |
|
183 |
+ lithuanian + czech + turkish + spanish + thai; |
|
184 |
||
185 |
private static String commandLineClassNameSuffix() { |
|
186 |
||
187 |
// Mapping from main platform encodings to language names |
|
188 |
// for Unix and Windows, respectively. Use empty suffix |
|
189 |
// for Windows encodings where OEM encoding differs. |
|
190 |
// Use null if encoding isn't used. |
|
191 |
String[][] names = { |
|
192 |
{ "UTF-8", unicode, "" }, |
|
193 |
{ "windows-1256", null, "" }, |
|
194 |
{ "iso-8859-6", arabic, null }, |
|
195 |
{ "GBK", s_chinese, s_chinese }, |
|
196 |
{ "GB18030", s_chinese, s_chinese }, |
|
197 |
{ "GB2312", s_chinese, null }, |
|
198 |
{ "x-windows-950", null, t_chinese }, |
|
199 |
{ "x-MS950-HKSCS", null, t_chinese }, |
|
200 |
{ "x-euc-tw", t_chinese, null }, |
|
201 |
{ "Big5", t_chinese, null }, |
|
202 |
{ "Big5-HKSCS", t_chinese, null }, |
|
203 |
{ "windows-1251", null, "" }, |
|
204 |
{ "iso-8859-5", russian, null }, |
|
205 |
{ "koi8-r", russian, null }, |
|
206 |
{ "windows-1253", null, "" }, |
|
207 |
{ "iso-8859-7", greek, null }, |
|
208 |
{ "windows-1255", null, "" }, |
|
209 |
{ "iso8859-8", hebrew, null }, |
|
210 |
{ "windows-31j", null, japanese }, |
|
211 |
{ "x-eucJP-Open", japanese, null }, |
|
212 |
{ "x-EUC-JP-LINUX", japanese, null }, |
|
213 |
{ "x-pck", japanese, null }, |
|
214 |
{ "x-windows-949", null, korean }, |
|
215 |
{ "euc-kr", korean, null }, |
|
216 |
{ "windows-1257", null, "" }, |
|
217 |
{ "iso-8859-13", lithuanian, null }, |
|
218 |
{ "windows-1250", null, "" }, |
|
219 |
{ "iso-8859-2", czech, null }, |
|
220 |
{ "windows-1254", null, "" }, |
|
221 |
{ "iso-8859-9", turkish, null }, |
|
222 |
{ "windows-1252", null, "" }, |
|
223 |
{ "iso-8859-1", spanish, null }, |
|
224 |
{ "iso-8859-15", spanish, null }, |
|
225 |
{ "x-windows-874", null, thai }, |
|
226 |
{ "tis-620", thai, null }, |
|
227 |
}; |
|
228 |
||
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
229 |
int column = isWindows ? 2 : 1; |
2 | 230 |
for (int i = 0; i < names.length; i++) { |
231 |
if (names[i][0].equalsIgnoreCase(defaultEncoding)) { |
|
232 |
return names[i][column]; |
|
233 |
} |
|
234 |
} |
|
235 |
return ""; |
|
236 |
} |
|
237 |
||
238 |
private static boolean hasUnicodeFileSystem() { |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
239 |
return (isWindows) ? true : defaultEncoding.equalsIgnoreCase("UTF-8"); |
2 | 240 |
} |
241 |
||
242 |
private static void generateSource(String thisClass, String otherClass) throws Exception { |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
243 |
File file = new File(UnicodeTestSrc, thisClass + JAVA_FILE_EXT); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
244 |
OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(file), "UTF-8"); |
2 | 245 |
out.write("public class " + thisClass + " {\n"); |
246 |
out.write(" public static void main(String[] args) {\n"); |
|
247 |
out.write(" if (!" + otherClass + "." + otherClass.toLowerCase() + "().equals(\"" + otherClass + "\")) {\n"); |
|
248 |
out.write(" throw new RuntimeException();\n"); |
|
249 |
out.write(" }\n"); |
|
250 |
out.write(" }\n"); |
|
251 |
out.write(" public static String " + thisClass.toLowerCase() + "() {\n"); |
|
252 |
out.write(" return \"" + thisClass + "\";\n"); |
|
253 |
out.write(" }\n"); |
|
254 |
out.write("}\n"); |
|
255 |
out.close(); |
|
256 |
} |
|
257 |
||
258 |
private static void generateManifest(String mainClass) throws Exception { |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
259 |
File file = new File(UnicodeTestSrc, "MANIFEST.MF"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
5506
diff
changeset
|
260 |
FileOutputStream out = new FileOutputStream(file); |
2 | 261 |
out.write("Manifest-Version: 1.0\n".getBytes("UTF-8")); |
262 |
// Header lines are limited to 72 bytes. |
|
263 |
// The manifest spec doesn't say we have to break at character boundaries, |
|
264 |
// so we rudely break at byte boundaries. |
|
265 |
byte[] headerBytes = ("Main-Class: " + mainClass + "\n").getBytes("UTF-8"); |
|
266 |
if (headerBytes.length <= 72) { |
|
267 |
out.write(headerBytes); |
|
268 |
} else { |
|
269 |
out.write(headerBytes, 0, 72); |
|
270 |
int start = 72; |
|
271 |
while (headerBytes.length > start) { |
|
272 |
out.write((byte) '\n'); |
|
273 |
out.write((byte) ' '); |
|
274 |
int count = Math.min(71, headerBytes.length - start); |
|
275 |
out.write(headerBytes, start, count); |
|
276 |
start += count; |
|
277 |
} |
|
278 |
} |
|
279 |
out.close(); |
|
280 |
} |
|
281 |
} |