JDK-8177314 : java VM fails to start with a Japanese ShiftJIS locale
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio.charsets
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: x86_64
  • Submitted: 2017-03-17
  • Updated: 2017-04-22
  • Resolved: 2017-04-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10 JDK 9
10Fixed 9 b166Fixed
Related Reports
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
$ LANG=C java -version
java version "9-ea"
Java(TM) SE Runtime Environment (build 9-ea+159)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+159, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Linux rhxxxxx.microfocus.com 2.6.32-131.0.15.el6.x86_64 #1 SMP Tue May 10 15:42:40 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux

EXTRA RELEVANT SYSTEM CONFIGURATION :
The locale must be set to Japanese ShiftJIS.

$ export LANG=ja_JP.SJIS
$ locale
LANG=ja_JP.SJIS
LC_CTYPE="ja_JP.SJIS"
LC_NUMERIC="ja_JP.SJIS"
LC_TIME="ja_JP.SJIS"
LC_COLLATE="ja_JP.SJIS"
LC_MONETARY="ja_JP.SJIS"
LC_MESSAGES="ja_JP.SJIS"
LC_PAPER="ja_JP.SJIS"
LC_NAME="ja_JP.SJIS"
LC_ADDRESS="ja_JP.SJIS"
LC_TELEPHONE="ja_JP.SJIS"
LC_MEASUREMENT="ja_JP.SJIS"
LC_IDENTIFICATION="ja_JP.SJIS"
LC_ALL=
$

A DESCRIPTION OF THE PROBLEM :
Invoking 'java' with the locale set to 'ja_JP.SJIS' fails immediately. Even to get the output from 'java -version' I have to temporarily set LANG to C (see the Development Kit or Runtime version).

REGRESSION.  Last worked in version 8u121

ADDITIONAL REGRESSION INFORMATION: 
java version "9-ea"
Java(TM) SE Runtime Environment (build 9-ea+159)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+159, mixed mode)


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Set the locale to be Japanese ShiftJIS - on Linux this is 'ja_JP.SJIS'.

$ export LANG=ja_JP.SJIS

... check the locale...

$ locale
LANG=ja_JP.SJIS
LC_CTYPE="ja_JP.SJIS"
LC_NUMERIC="ja_JP.SJIS"
LC_TIME="ja_JP.SJIS"
LC_COLLATE="ja_JP.SJIS"
LC_MONETARY="ja_JP.SJIS"
LC_MESSAGES="ja_JP.SJIS"
LC_PAPER="ja_JP.SJIS"
LC_NAME="ja_JP.SJIS"
LC_ADDRESS="ja_JP.SJIS"
LC_TELEPHONE="ja_JP.SJIS"
LC_MEASUREMENT="ja_JP.SJIS"
LC_IDENTIFICATION="ja_JP.SJIS"
LC_ALL=

.. which should be what you set, i.e. ja_JP.SJIS.
.. And run java. 

$ java

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The usual Java usage options - in Japanese. 
But if I set 'LC_MESSAGES' to C I can read it (I can't read Japanese!) and more importantly at this point, cut and paste it...

$ export LC_MESSAGES=C
$ java
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)
where options include:
... and so on 

ACTUAL -
$ export LANG=ja_JP.SJIS
$ locale
LANG=ja_JP.SJIS
LC_CTYPE="ja_JP.SJIS"
LC_NUMERIC="ja_JP.SJIS"
LC_TIME="ja_JP.SJIS"
LC_COLLATE="ja_JP.SJIS"
LC_MONETARY="ja_JP.SJIS"
LC_MESSAGES="ja_JP.SJIS"
LC_PAPER="ja_JP.SJIS"
LC_NAME="ja_JP.SJIS"
LC_ADDRESS="ja_JP.SJIS"
LC_TELEPHONE="ja_JP.SJIS"
LC_MEASUREMENT="ja_JP.SJIS"
LC_IDENTIFICATION="ja_JP.SJIS"
LC_ALL=
$ java
Error occurred during initialization of VM
java.lang.ExceptionInInitializerError
        at sun.nio.fs.UnixFileSystem.<init>(java.base/UnixFileSystem.java:51)
        at sun.nio.fs.LinuxFileSystem.<init>(java.base/LinuxFileSystem.java:39)
        at sun.nio.fs.LinuxFileSystemProvider.newFileSystem(java.base/LinuxFileSystemProvider.java:46)
        at sun.nio.fs.LinuxFileSystemProvider.newFileSystem(java.base/LinuxFileSystemProvider.java:39)
        at sun.nio.fs.UnixFileSystemProvider.<init>(java.base/UnixFileSystemProvider.java:56)
        at sun.nio.fs.LinuxFileSystemProvider.<init>(java.base/LinuxFileSystemProvider.java:41)
        at sun.nio.fs.DefaultFileSystemProvider.create(java.base/DefaultFileSystemProvider.java:41)
        at java.nio.file.FileSystems.<clinit>(java.base/FileSystems.java:91)
        at java.nio.file.Paths.get(java.base/Paths.java:84)
        at java.lang.module.ModuleFinder.ofSystem(java.base/ModuleFinder.java:171)
        at jdk.internal.module.ModuleBootstrap.boot(java.base/ModuleBootstrap.java:118)
        at java.lang.System.initPhase2(java.base/System.java:1928)
Caused by: java.nio.charset.UnsupportedCharsetException: SHIFT_JIS
        at java.nio.charset.Charset.forName(java.base/Charset.java:536)
        at sun.nio.fs.Util.<clinit>(java.base/Util.java:40)
        at sun.nio.fs.UnixFileSystem.<init>(java.base/UnixFileSystem.java:51)
        at sun.nio.fs.LinuxFileSystem.<init>(java.base/LinuxFileSystem.java:39)
        at sun.nio.fs.LinuxFileSystemProvider.newFileSystem(java.base/LinuxFileSystemProvider.java:46)
        at sun.nio.fs.LinuxFileSystemProvider.newFileSystem(java.base/LinuxFileSystemProvider.java:39)
        at sun.nio.fs.UnixFileSystemProvider.<init>(java.base/UnixFileSystemProvider.java:56)
        at sun.nio.fs.LinuxFileSystemProvider.<init>(java.base/LinuxFileSystemProvider.java:41)
        at sun.nio.fs.DefaultFileSystemProvider.create(java.base/DefaultFileSystemProvider.java:41)
        at java.nio.file.FileSystems.<clinit>(java.base/FileSystems.java:91)
        at java.nio.file.Paths.get(java.base/Paths.java:84)
        at java.lang.module.ModuleFinder.ofSystem(java.base/ModuleFinder.java:171)
        at jdk.internal.module.ModuleBootstrap.boot(java.base/ModuleBootstrap.java:118)
        at java.lang.System.initPhase2(java.base/System.java:1928)




ERROR MESSAGES/STACK TRACES THAT OCCUR :
Error occurred during initialization of VM
java.lang.ExceptionInInitializerError
        at sun.nio.fs.UnixFileSystem.<init>(java.base/UnixFileSystem.java:51)
        at sun.nio.fs.LinuxFileSystem.<init>(java.base/LinuxFileSystem.java:39)
        at sun.nio.fs.LinuxFileSystemProvider.newFileSystem(java.base/LinuxFileSystemProvider.java:46)
        at sun.nio.fs.LinuxFileSystemProvider.newFileSystem(java.base/LinuxFileSystemProvider.java:39)
        at sun.nio.fs.UnixFileSystemProvider.<init>(java.base/UnixFileSystemProvider.java:56)
        at sun.nio.fs.LinuxFileSystemProvider.<init>(java.base/LinuxFileSystemProvider.java:41)
        at sun.nio.fs.DefaultFileSystemProvider.create(java.base/DefaultFileSystemProvider.java:41)
        at java.nio.file.FileSystems.<clinit>(java.base/FileSystems.java:91)
        at java.nio.file.Paths.get(java.base/Paths.java:84)
        at java.lang.module.ModuleFinder.ofSystem(java.base/ModuleFinder.java:171)
        at jdk.internal.module.ModuleBootstrap.boot(java.base/ModuleBootstrap.java:118)
        at java.lang.System.initPhase2(java.base/System.java:1928)
Caused by: java.nio.charset.UnsupportedCharsetException: SHIFT_JIS
        at java.nio.charset.Charset.forName(java.base/Charset.java:536)
        at sun.nio.fs.Util.<clinit>(java.base/Util.java:40)
        at sun.nio.fs.UnixFileSystem.<init>(java.base/UnixFileSystem.java:51)
        at sun.nio.fs.LinuxFileSystem.<init>(java.base/LinuxFileSystem.java:39)
        at sun.nio.fs.LinuxFileSystemProvider.newFileSystem(java.base/LinuxFileSystemProvider.java:46)
        at sun.nio.fs.LinuxFileSystemProvider.newFileSystem(java.base/LinuxFileSystemProvider.java:39)
        at sun.nio.fs.UnixFileSystemProvider.<init>(java.base/UnixFileSystemProvider.java:56)
        at sun.nio.fs.LinuxFileSystemProvider.<init>(java.base/LinuxFileSystemProvider.java:41)
        at sun.nio.fs.DefaultFileSystemProvider.create(java.base/DefaultFileSystemProvider.java:41)
        at java.nio.file.FileSystems.<clinit>(java.base/FileSystems.java:91)
        at java.nio.file.Paths.get(java.base/Paths.java:84)
        at java.lang.module.ModuleFinder.ofSystem(java.base/ModuleFinder.java:171)
        at jdk.internal.module.ModuleBootstrap.boot(java.base/ModuleBootstrap.java:118)
        at java.lang.System.initPhase2(java.base/System.java:1928)


REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
None - I need to use the ShiftJIS locale.


Comments
Maybe this webrev is also needed to apply the other patch.
15-04-2017

Here is an older webrev to fix the problem. Maybe it give some help.
15-04-2017

This is approved for JDK 9 as there may be customers running with the locale set to ja_JP.SJIS.
15-04-2017

With a locale created by "localedef" command: localedef -f SHIFT_JIS -i ja_JP ja_JP.SJIS The issue is reproducible on Oracle Linux.
14-04-2017

If starting up with Shift_JIS is indeed not supported, this bug should be downgraded from P3 and the "regression" label should be removed.
28-03-2017

The charsets that are potentially needed during startup for all supported configurations have to be in the java.base module. Additional charsets (jdk.charsets module) can be loaded after the system is initialized. As things currently stand on Linux then java.base includes: JIS_X0201 JIS_X0212-1990 x-JIS0208 but does not include: Shift_JIS x-JISAutoDetect x-SJIS_0213 So I think the question in this issue is whether startup with the ja_JP.SJIS locale is a supported configuration or not.
21-03-2017

There was a similar bug JDK-6795536 even in Java 7. Unfortunately the there attached fix is lost.
21-03-2017