author | ksrini |
Wed, 11 Jan 2012 08:14:47 -0800 | |
changeset 11520 | 1c485b79de81 |
child 11687 | f13cadbb0bb5 |
permissions | -rw-r--r-- |
11520
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
1 |
/* |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
2 |
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
4 |
* |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
8 |
* |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
13 |
* accompanied this code). |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
14 |
* |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
18 |
* |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
21 |
* questions. |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
22 |
*/ |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
23 |
|
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
24 |
/* |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
25 |
* @test |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
26 |
* @bug 7125442 |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
27 |
* @summary ensures a jar path as well as a class located in a path containing |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
28 |
* unicode characters are launched. |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
29 |
* @compile -XDignore.symbol.file I18NJarTest.java TestHelper.java |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
30 |
* @run main/othervm I18NJarTest |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
31 |
*/ |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
32 |
import java.io.File; |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
33 |
import java.util.Locale; |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
34 |
|
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
35 |
/* |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
36 |
* Note 1: the system must have the correct Locale, in order for the test to |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
37 |
* work correctly, on those systems that do not comply, the test will succeed. |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
38 |
* Here are some guidelines to set the locale correctly. |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
39 |
* On Windows: ControlPanel->Regional Settings, |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
40 |
* ensure that "Japanese" is selected and checked, and in |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
41 |
* "Code page conversion tables", the following must be checked, |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
42 |
* 932 (ANSI/OEM - Japanese Shift-JIS). |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
43 |
* On Unix: use "locale -a" verify one of these exist ja_JP.UTF-8 or |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
44 |
* ja_JP.utf8 or ja_JP.ujis, and export one of them with LC_ALL. |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
45 |
* |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
46 |
* |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
47 |
* Note 2: since we need to set the locale, it is safest to execute this test |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
48 |
* in its own VM (othervm mode), such that the ensuing tests can run unperturbed, |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
49 |
* regardless of the outcome. |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
50 |
*/ |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
51 |
public class I18NJarTest { |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
52 |
private static final File cwd = new File("."); |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
53 |
private static final File dir = new File("\uFF66\uFF67\uFF68\uFF69"); |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
54 |
private static final String encoding = System.getProperty("sun.jnu.encoding", ""); |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
55 |
|
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
56 |
public static void main(String... args) throws Exception { |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
57 |
boolean localeAvailable = false; |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
58 |
for (Locale l : Locale.getAvailableLocales()) { |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
59 |
if (l.toLanguageTag().equals(Locale.JAPAN.toLanguageTag())) { |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
60 |
localeAvailable = true; |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
61 |
break; |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
62 |
} |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
63 |
} |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
64 |
if (!localeAvailable) { |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
65 |
System.out.println("Warning: locale: " + Locale.JAPAN |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
66 |
+ " not found, test passes vacuosly"); |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
67 |
return; |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
68 |
} |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
69 |
if (encoding.equals("MS932") || encoding.equals("UTF-8")) { |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
70 |
Locale.setDefault(Locale.JAPAN); |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
71 |
System.out.println("using locale " + Locale.JAPAN + |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
72 |
", encoding " + encoding); |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
73 |
} else { |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
74 |
System.out.println("Warning: current encoding is " + encoding + |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
75 |
"this test requires MS932 <Ja> or UTF-8," + |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
76 |
" test passes vacuosly"); |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
77 |
return; |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
78 |
} |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
79 |
dir.mkdir(); |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
80 |
File dirfile = new File(dir, "foo.jar"); |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
81 |
TestHelper.createJar(dirfile, |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
82 |
"public static void main(String... args) {", |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
83 |
"System.out.println(\"Hello World\");", |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
84 |
"System.exit(0);", |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
85 |
"}"); |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
86 |
|
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
87 |
// remove the class files, to ensure that the class is indeed picked up |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
88 |
// from the jar file and not from ambient classpath. |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
89 |
File[] classFiles = cwd.listFiles(TestHelper.createFilter(TestHelper.CLASS_FILE_EXT)); |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
90 |
for (File f : classFiles) { |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
91 |
f.delete(); |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
92 |
} |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
93 |
|
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
94 |
// test with a jar file |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
95 |
TestHelper.TestResult tr = TestHelper.doExec(TestHelper.javaCmd, |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
96 |
"-jar", dirfile.getAbsolutePath()); |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
97 |
System.out.println(tr); |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
98 |
if (!tr.isOK()) { |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
99 |
throw new RuntimeException("TEST FAILED"); |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
100 |
} |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
101 |
|
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
102 |
// test the same class but by specifying it as a classpath |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
103 |
tr = TestHelper.doExec(TestHelper.javaCmd, "-cp", |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
104 |
dirfile.getAbsolutePath(), "Foo"); |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
105 |
System.out.println(tr); |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
106 |
if (!tr.isOK()) { |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
107 |
throw new RuntimeException("TEST FAILED"); |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
108 |
} |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
109 |
} |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
diff
changeset
|
110 |
} |