8229960: Remove sun.nio.cs.map system property
Reviewed-by: alanb
This commit is contained in:
parent
7c2fe7025b
commit
28b972e5ce
@ -592,9 +592,6 @@ charset x-mswin-936 MS936
|
|||||||
alias ms936 # JDK historical
|
alias ms936 # JDK historical
|
||||||
alias ms_936 // IANA aliases
|
alias ms_936 // IANA aliases
|
||||||
|
|
||||||
# The definition of this charset may be overridden by the init method,
|
|
||||||
# below, if the sun.nio.cs.map property is defined.
|
|
||||||
#
|
|
||||||
charset Shift_JIS SJIS
|
charset Shift_JIS SJIS
|
||||||
package sun.nio.cs.ext
|
package sun.nio.cs.ext
|
||||||
type dbcs
|
type dbcs
|
||||||
@ -609,8 +606,6 @@ charset Shift_JIS SJIS
|
|||||||
alias x-sjis
|
alias x-sjis
|
||||||
alias csShiftJIS
|
alias csShiftJIS
|
||||||
|
|
||||||
# The definition of this charset may be overridden by the init method,
|
|
||||||
# below, if the sun.nio.cs.map property is defined.
|
|
||||||
charset windows-31j MS932
|
charset windows-31j MS932
|
||||||
package sun.nio.cs.ext
|
package sun.nio.cs.ext
|
||||||
type dbcs
|
type dbcs
|
||||||
|
@ -25,4 +25,4 @@ JIS_X_0212
|
|||||||
JIS_X_0208_Solaris
|
JIS_X_0208_Solaris
|
||||||
JIS_X_0212_Solaris
|
JIS_X_0212_Solaris
|
||||||
MS932
|
MS932
|
||||||
SJIS # SJIS must go together with MS932 to support sun.nio.cs.map
|
SJIS
|
||||||
|
@ -8,8 +8,8 @@ MS1256
|
|||||||
MS1258
|
MS1258
|
||||||
MS874
|
MS874
|
||||||
MS932
|
MS932
|
||||||
JIS_X_0201 # JIS_X_0201 is used by MS932 in its contains() method
|
JIS_X_0201
|
||||||
SJIS # SJIS must go together with MS932 to support sun.nio.cs.map
|
SJIS
|
||||||
MS936
|
MS936
|
||||||
MS949
|
MS949
|
||||||
MS950
|
MS950
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
*
|
*
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
@ -35,7 +35,6 @@ import java.util.Iterator;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import jdk.internal.vm.annotation.Stable;
|
import jdk.internal.vm.annotation.Stable;
|
||||||
import sun.security.action.GetPropertyAction;
|
|
||||||
|
|
||||||
public class StandardCharsets extends CharsetProvider {
|
public class StandardCharsets extends CharsetProvider {
|
||||||
|
|
||||||
@ -120,8 +119,6 @@ public class StandardCharsets extends CharsetProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Charset lookup(String charsetName) {
|
private Charset lookup(String charsetName) {
|
||||||
init();
|
|
||||||
|
|
||||||
// By checking these built-ins we can avoid initializing Aliases,
|
// By checking these built-ins we can avoid initializing Aliases,
|
||||||
// Classes and Cache eagerly during bootstrap.
|
// Classes and Cache eagerly during bootstrap.
|
||||||
//
|
//
|
||||||
@ -177,7 +174,6 @@ public class StandardCharsets extends CharsetProvider {
|
|||||||
public final Iterator<Charset> charsets() {
|
public final Iterator<Charset> charsets() {
|
||||||
Set<String> charsetNames;
|
Set<String> charsetNames;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
init();
|
|
||||||
// Ensure initialized in synchronized block
|
// Ensure initialized in synchronized block
|
||||||
charsetNames = classMap().keySet();
|
charsetNames = classMap().keySet();
|
||||||
aliasMap();
|
aliasMap();
|
||||||
@ -202,53 +198,4 @@ public class StandardCharsets extends CharsetProvider {
|
|||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean initialized = false;
|
|
||||||
|
|
||||||
/* provider the sun.nio.cs.map property fir sjis/ms932 mapping hack
|
|
||||||
*/
|
|
||||||
private void init() {
|
|
||||||
if (initialized)
|
|
||||||
return;
|
|
||||||
if (!jdk.internal.misc.VM.isBooted())
|
|
||||||
return;
|
|
||||||
initialized = true;
|
|
||||||
|
|
||||||
String map = GetPropertyAction.privilegedGetProperty("sun.nio.cs.map");
|
|
||||||
if (map != null) {
|
|
||||||
Map<String,String> aliasMap = aliasMap();
|
|
||||||
Map<String,String> classMap = classMap();
|
|
||||||
String[] maps = map.split(",");
|
|
||||||
for (int i = 0; i < maps.length; i++) {
|
|
||||||
if (maps[i].equalsIgnoreCase("Windows-31J/Shift_JIS")) {
|
|
||||||
// if we dont have both sjis and ms932, do nothing
|
|
||||||
if (classMap.get("shift_jis") == null ||
|
|
||||||
classMap.get("windows-31j") == null) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
aliases_MS932 = new String[] {
|
|
||||||
"MS932", // JDK historical
|
|
||||||
"windows-932",
|
|
||||||
"csWindows31J",
|
|
||||||
"shift-jis",
|
|
||||||
"ms_kanji",
|
|
||||||
"x-sjis",
|
|
||||||
"csShiftJIS",
|
|
||||||
// This alias takes precedence over the actual
|
|
||||||
// Shift_JIS charset itself since aliases are always
|
|
||||||
// resolved first, before looking up canonical names.
|
|
||||||
"shift_jis"
|
|
||||||
};
|
|
||||||
aliases_SJIS = new String[] { "sjis" };
|
|
||||||
|
|
||||||
for (String alias : aliases_MS932) {
|
|
||||||
aliasMap.put(toLower(alias), "windows-31j");
|
|
||||||
}
|
|
||||||
cache().put("shift_jis", null);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,6 @@ grant codeBase "jrt:/jdk.accessibility" {
|
|||||||
|
|
||||||
grant codeBase "jrt:/jdk.charsets" {
|
grant codeBase "jrt:/jdk.charsets" {
|
||||||
permission java.util.PropertyPermission "os.name", "read";
|
permission java.util.PropertyPermission "os.name", "read";
|
||||||
permission java.util.PropertyPermission "sun.nio.cs.map", "read";
|
|
||||||
permission java.lang.RuntimePermission "charsetProvider";
|
permission java.lang.RuntimePermission "charsetProvider";
|
||||||
permission java.lang.RuntimePermission
|
permission java.lang.RuntimePermission
|
||||||
"accessClassInPackage.jdk.internal.misc";
|
"accessClassInPackage.jdk.internal.misc";
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
*
|
*
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
@ -29,11 +29,8 @@
|
|||||||
|
|
||||||
package sun.nio.cs.ext;
|
package sun.nio.cs.ext;
|
||||||
|
|
||||||
import java.lang.ref.SoftReference;
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.charset.spi.CharsetProvider;
|
import java.nio.charset.spi.CharsetProvider;
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provider for extended charsets.
|
* Provider for extended charsets.
|
||||||
@ -53,188 +50,6 @@ public class ExtendedCharsets extends AbstractCharsetProvider {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean initialized = false;
|
|
||||||
|
|
||||||
// If the sun.nio.cs.map property is defined on the command line we won't
|
|
||||||
// see it in the system-properties table until after the charset subsystem
|
|
||||||
// has been initialized. We therefore delay the effect of this property
|
|
||||||
// until after the JRE has completely booted.
|
|
||||||
//
|
|
||||||
// At the moment following values for this property are supported, property
|
|
||||||
// value string is case insensitive.
|
|
||||||
//
|
|
||||||
// (1)"Windows-31J/Shift_JIS"
|
|
||||||
// In 1.4.1 we added a correct implementation of the Shift_JIS charset
|
|
||||||
// but in previous releases this charset name had been treated as an alias
|
|
||||||
// for Windows-31J, aka MS932. Users who have existing code that depends
|
|
||||||
// upon this alias can restore the previous behavior by defining this
|
|
||||||
// property to have this value.
|
|
||||||
//
|
|
||||||
// (2)"x-windows-50221/ISO-2022-JP"
|
|
||||||
// "x-windows-50220/ISO-2022-JP"
|
|
||||||
// "x-windows-iso2022jp/ISO-2022-JP"
|
|
||||||
// The charset ISO-2022-JP is a "standard based" implementation by default,
|
|
||||||
// which supports ASCII, JIS_X_0201 and JIS_X_0208 mappings based encoding
|
|
||||||
// and decoding only.
|
|
||||||
// There are three Microsoft iso-2022-jp variants, namely x-windows-50220,
|
|
||||||
// x-windows-50221 and x-windows-iso2022jp which behaves "slightly" differently
|
|
||||||
// compared to the "standard based" implementation. See ISO2022_JP.java for
|
|
||||||
// detailed description. Users who prefer the behavior of MS iso-2022-jp
|
|
||||||
// variants should use these names explicitly instead of using "ISO-2022-JP"
|
|
||||||
// and its aliases. However for those who need the ISO-2022-JP charset behaves
|
|
||||||
// exactly the same as MS variants do, above properties can be defined to
|
|
||||||
// switch.
|
|
||||||
//
|
|
||||||
// If we need to define other charset-alias mappings in the future then
|
|
||||||
// this property could be further extended, the general idea being that its
|
|
||||||
// value should be of the form
|
|
||||||
//
|
|
||||||
// new-charset-1/old-charset-1,new-charset-2/old-charset-2,...
|
|
||||||
//
|
|
||||||
// where each charset named to the left of a slash is intended to replace
|
|
||||||
// (most) uses of the charset named to the right of the slash.
|
|
||||||
//
|
|
||||||
protected void init() {
|
|
||||||
if (initialized)
|
|
||||||
return;
|
|
||||||
if (!jdk.internal.misc.VM.isBooted())
|
|
||||||
return;
|
|
||||||
|
|
||||||
String map = getProperty("sun.nio.cs.map");
|
|
||||||
boolean sjisIsMS932 = false;
|
|
||||||
boolean iso2022jpIsMS50221 = false;
|
|
||||||
boolean iso2022jpIsMS50220 = false;
|
|
||||||
boolean iso2022jpIsMSISO2022JP = false;
|
|
||||||
if (map != null) {
|
|
||||||
String[] maps = map.split(",");
|
|
||||||
for (int i = 0; i < maps.length; i++) {
|
|
||||||
if (maps[i].equalsIgnoreCase("Windows-31J/Shift_JIS")) {
|
|
||||||
sjisIsMS932 = true;
|
|
||||||
} else if (maps[i].equalsIgnoreCase("x-windows-50221/ISO-2022-JP")) {
|
|
||||||
iso2022jpIsMS50221 = true;
|
|
||||||
} else if (maps[i].equalsIgnoreCase("x-windows-50220/ISO-2022-JP")) {
|
|
||||||
iso2022jpIsMS50220 = true;
|
|
||||||
} else if (maps[i].equalsIgnoreCase("x-windows-iso2022jp/ISO-2022-JP")) {
|
|
||||||
iso2022jpIsMSISO2022JP = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (sjisIsMS932 && hasCharset("Shift_JIS")) {
|
|
||||||
deleteCharset("Shift_JIS",
|
|
||||||
new String[] {
|
|
||||||
// IANA aliases
|
|
||||||
"sjis", // historical
|
|
||||||
"shift_jis",
|
|
||||||
"shift-jis",
|
|
||||||
"ms_kanji",
|
|
||||||
"x-sjis",
|
|
||||||
"csShiftJIS"
|
|
||||||
});
|
|
||||||
deleteCharset("windows-31j",
|
|
||||||
new String[] {
|
|
||||||
"MS932", // JDK historical
|
|
||||||
"windows-932",
|
|
||||||
"csWindows31J"
|
|
||||||
});
|
|
||||||
charset("Shift_JIS", "SJIS",
|
|
||||||
new String[] {
|
|
||||||
// IANA aliases
|
|
||||||
"sjis" // JDK historical
|
|
||||||
});
|
|
||||||
charset("windows-31j", "MS932",
|
|
||||||
new String[] {
|
|
||||||
"MS932", // JDK historical
|
|
||||||
"windows-932",
|
|
||||||
"csWindows31J",
|
|
||||||
"shift-jis",
|
|
||||||
"ms_kanji",
|
|
||||||
"x-sjis",
|
|
||||||
"csShiftJIS",
|
|
||||||
// This alias takes precedence over the actual
|
|
||||||
// Shift_JIS charset itself since aliases are always
|
|
||||||
// resolved first, before looking up canonical names.
|
|
||||||
"shift_jis"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (iso2022jpIsMS50221 ||
|
|
||||||
iso2022jpIsMS50220 ||
|
|
||||||
iso2022jpIsMSISO2022JP) {
|
|
||||||
deleteCharset("ISO-2022-JP",
|
|
||||||
new String[] {
|
|
||||||
"iso2022jp",
|
|
||||||
"jis",
|
|
||||||
"csISO2022JP",
|
|
||||||
"jis_encoding",
|
|
||||||
"csjisencoding"
|
|
||||||
});
|
|
||||||
if (iso2022jpIsMS50221) {
|
|
||||||
deleteCharset("x-windows-50221",
|
|
||||||
new String[] {
|
|
||||||
"cp50221",
|
|
||||||
"ms50221"
|
|
||||||
});
|
|
||||||
charset("x-windows-50221", "MS50221",
|
|
||||||
new String[] {
|
|
||||||
"cp50221",
|
|
||||||
"ms50221",
|
|
||||||
"iso-2022-jp",
|
|
||||||
"iso2022jp",
|
|
||||||
"jis",
|
|
||||||
"csISO2022JP",
|
|
||||||
"jis_encoding",
|
|
||||||
"csjisencoding"
|
|
||||||
});
|
|
||||||
} else if (iso2022jpIsMS50220) {
|
|
||||||
deleteCharset("x-windows-50220",
|
|
||||||
new String[] {
|
|
||||||
"cp50220",
|
|
||||||
"ms50220"
|
|
||||||
});
|
|
||||||
charset("x-windows-50220", "MS50220",
|
|
||||||
new String[] {
|
|
||||||
"cp50220",
|
|
||||||
"ms50220",
|
|
||||||
"iso-2022-jp",
|
|
||||||
"iso2022jp",
|
|
||||||
"jis",
|
|
||||||
"csISO2022JP",
|
|
||||||
"jis_encoding",
|
|
||||||
"csjisencoding"
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
deleteCharset("x-windows-iso2022jp",
|
|
||||||
new String[] {
|
|
||||||
"windows-iso2022jp"
|
|
||||||
});
|
|
||||||
charset("x-windows-iso2022jp", "MSISO2022JP",
|
|
||||||
new String[] {
|
|
||||||
"windows-iso2022jp",
|
|
||||||
"iso-2022-jp",
|
|
||||||
"iso2022jp",
|
|
||||||
"jis",
|
|
||||||
"csISO2022JP",
|
|
||||||
"jis_encoding",
|
|
||||||
"csjisencoding"
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
initialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getProperty(String key) {
|
|
||||||
// this method may be called during initialization of
|
|
||||||
// system class loader and thus not using lambda
|
|
||||||
return AccessController.doPrivileged(
|
|
||||||
new PrivilegedAction<String>() {
|
|
||||||
@Override
|
|
||||||
public String run() {
|
|
||||||
return System.getProperty(key);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String[] aliasesFor(String charsetName) {
|
public static String[] aliasesFor(String charsetName) {
|
||||||
if (instance == null)
|
if (instance == null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -22,13 +22,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* @test
|
/* @test
|
||||||
* @bug 4712786
|
* @bug 4712786 8229960
|
||||||
* @summary Check charsets against reference files
|
* @summary Check charsets against reference files
|
||||||
* @modules jdk.charsets
|
* @modules jdk.charsets
|
||||||
*
|
*
|
||||||
* @build Util
|
* @build Util
|
||||||
* @run main Check shift_jis ref.shift_jis
|
* @run main Check shift_jis ref.shift_jis
|
||||||
* @run main/othervm -Dsun.nio.cs.map=Windows-31J/Shift_JIS Check shift_jis ref.windows-31j
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
@ -1,92 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
||||||
*
|
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @test
|
|
||||||
* @bug 4879123
|
|
||||||
* @summary Verify that sun.nio.cs.map property interpreted in ja multibyte locales
|
|
||||||
* @requires (os.family != "windows")
|
|
||||||
* @modules jdk.charsets
|
|
||||||
* @library /test/lib
|
|
||||||
* @build jdk.test.lib.Utils
|
|
||||||
* jdk.test.lib.Asserts
|
|
||||||
* jdk.test.lib.JDKToolFinder
|
|
||||||
* jdk.test.lib.JDKToolLauncher
|
|
||||||
* jdk.test.lib.Platform
|
|
||||||
* jdk.test.lib.process.*
|
|
||||||
* SJISPropTest
|
|
||||||
* @run testng SJISMappingPropTest
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import jdk.test.lib.process.OutputAnalyzer;
|
|
||||||
import jdk.test.lib.process.ProcessTools;
|
|
||||||
|
|
||||||
import org.testng.annotations.DataProvider;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
|
|
||||||
public class SJISMappingPropTest {
|
|
||||||
|
|
||||||
@DataProvider
|
|
||||||
public static Iterator<Object[]> locales() {
|
|
||||||
List<Object[]> data = new ArrayList<>();
|
|
||||||
data.add(new String[]{"ja"});
|
|
||||||
data.add(new String[]{"ja_JP.PCK"});
|
|
||||||
data.add(new String[]{"ja_JP.eucJP"});
|
|
||||||
return data.iterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProvider = "locales")
|
|
||||||
public void testWithProperty(String locale) throws Exception {
|
|
||||||
// with property set, shift_jis should map to windows-31J charset
|
|
||||||
runTest(locale,
|
|
||||||
"-Dsun.nio.cs.map=Windows-31J/Shift_JIS",
|
|
||||||
SJISPropTest.class.getName(),
|
|
||||||
"MS932");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProvider = "locales")
|
|
||||||
public void testWithoutProperty(String locale) throws Exception {
|
|
||||||
// without property set - "shift_jis" follows IANA conventions
|
|
||||||
// and should map to the sun.nio.cs.ext.Shift_JIS charset
|
|
||||||
runTest(locale,
|
|
||||||
SJISPropTest.class.getName(),
|
|
||||||
"Shift_JIS");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void runTest(String locale, String... cmd) throws Exception {
|
|
||||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmd);
|
|
||||||
Map<String, String> env = pb.environment();
|
|
||||||
env.put("LC_ALL", locale);
|
|
||||||
OutputAnalyzer out = ProcessTools.executeProcess(pb)
|
|
||||||
.outputTo(System.out)
|
|
||||||
.errorTo(System.err);
|
|
||||||
assertEquals(out.getExitValue(), 0);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
|
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
||||||
*
|
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Regression test class run by SJISMappingPropTest.java to verify
|
|
||||||
* that sun.nio.cs.map property is correctly interpreted in
|
|
||||||
* multibyte Japanese locales
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class SJISPropTest {
|
|
||||||
public static void main(String[] args) throws Exception {
|
|
||||||
boolean sjisIsMS932 = false;
|
|
||||||
|
|
||||||
if (args[0].equals("MS932"))
|
|
||||||
sjisIsMS932 = true;
|
|
||||||
byte[] testBytes = { (byte)0x81, (byte)0x60 };
|
|
||||||
|
|
||||||
// JIS X based Shift_JIS and Windows-31J differ
|
|
||||||
// in a number of mappings including this one.
|
|
||||||
|
|
||||||
String expectedMS932 = new String("\uFF5E");
|
|
||||||
String expectedSJIS = new String("\u301C");
|
|
||||||
|
|
||||||
// Alias "shift_jis" will map to Windows-31J
|
|
||||||
// if the sun.nio.cs.map system property is defined as
|
|
||||||
// "Windows-31J/Shift_JIS". This should work in all
|
|
||||||
// multibyte (especially Japanese) locales.
|
|
||||||
|
|
||||||
String s = new String(testBytes, "shift_jis");
|
|
||||||
|
|
||||||
if (sjisIsMS932 && !s.equals(expectedMS932))
|
|
||||||
throw new Exception("not MS932");
|
|
||||||
else if (!sjisIsMS932 && !s.equals(expectedSJIS))
|
|
||||||
throw new Exception("not SJIS");
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,6 @@
|
|||||||
grant codeBase "jrt:/jdk.charsets" {
|
grant codeBase "jrt:/jdk.charsets" {
|
||||||
permission java.io.FilePermission "${java.home}/-", "read";
|
permission java.io.FilePermission "${java.home}/-", "read";
|
||||||
permission java.util.PropertyPermission "os.name", "read";
|
permission java.util.PropertyPermission "os.name", "read";
|
||||||
permission java.util.PropertyPermission "sun.nio.cs.map", "read";
|
|
||||||
permission java.lang.RuntimePermission "charsetProvider";
|
permission java.lang.RuntimePermission "charsetProvider";
|
||||||
permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.misc";
|
permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.misc";
|
||||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.cs";
|
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.cs";
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -22,7 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* @test
|
/* @test
|
||||||
* @bug 6173388 6319716
|
* @bug 6173388 6319716 8229960
|
||||||
* @summary Check full coverage encode/decode for Microsoft
|
* @summary Check full coverage encode/decode for Microsoft
|
||||||
* ISO2022_JP variants MS50220, MS50221 and MSISO2022JP
|
* ISO2022_JP variants MS50220, MS50221 and MSISO2022JP
|
||||||
* @modules jdk.charsets
|
* @modules jdk.charsets
|
||||||
@ -666,23 +666,6 @@ public class TestMS5022X {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
String map = System.getProperty("sun.nio.cs.map");
|
|
||||||
if (map != null) {
|
|
||||||
map = map.toLowerCase(java.util.Locale.US);
|
|
||||||
Charset cs = Charset.forName("ISO-2022-JP");
|
|
||||||
if (map.indexOf("x-windows-50221/ISO-2022-jp") != -1 &&
|
|
||||||
!"x-windows-50220".equals(cs.name()) ||
|
|
||||||
map.indexOf("x-windows-50220/ISO-2022-jp") != -1 &&
|
|
||||||
!"x-windows-50220".equals(cs.name()) ||
|
|
||||||
map.indexOf("x-windows-iso2022jp/ISO-2022-jp") != -1 &&
|
|
||||||
!"x-windows-iso2022jp".equals(cs.name())) {
|
|
||||||
throw new Exception("Error: sun.nio.cs.map=" + map +
|
|
||||||
", ISO-2022-JP=" + cs.name());
|
|
||||||
} else {
|
|
||||||
System.out.printf("ISO-2022-JP=%s\n", cs.name());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String testStr = US_ASCII +
|
String testStr = US_ASCII +
|
||||||
JISX0208SUBSET +
|
JISX0208SUBSET +
|
||||||
JISX0201KATAKANA +
|
JISX0201KATAKANA +
|
||||||
|
Loading…
x
Reference in New Issue
Block a user