JDK-8226810 : Failed to launch JVM because of NullPointerException occured on System.props
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 9.0.4,11.0.1,12.0.1,17
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2019-06-24
  • Updated: 2021-12-09
  • Resolved: 2021-01-12
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 11 JDK 13 JDK 15 JDK 16 JDK 17
11.0.11-oracleFixed 13.0.6Fixed 15.0.6Fixed 16.0.1Fixed 17 b05Fixed
Description
ADDITIONAL SYSTEM INFORMATION :
OS: Windows10 1607 (internal version 14393.2430)
Java: 12.0.1, extracted from the official release package jdk-12.0.1_windows-x64_bin.zip.

A DESCRIPTION OF THE PROBLEM :
Try to launch the JVM on windows10, with command line "java -version"; and it failed due to NullPointerException on java.base/java.lang.System.props,  with the following stacks:

Error occurred during initialization of VM
java.lang.NullPointerException
        at java.lang.System.getProperty(java.base/System.java:848)
        at sun.security.action.GetPropertyAction.privilegedGetProperty(java.base/GetPropertyAction.java:105)
        at java.nio.charset.Charset.defaultCharset(java.base/Charset.java:607)
        at java.lang.StringCoding.decode(java.base/StringCoding.java:316)
        at java.lang.String.<init>(java.base/String.java:601)
        at java.lang.String.<init>(java.base/String.java:623)
        at jdk.internal.util.SystemProps$Raw.vmProperties(java.base/Native Method)
        at jdk.internal.util.SystemProps$Raw.cmdProperties(java.base/SystemProps.java:261)
        at jdk.internal.util.SystemProps.initProperties(java.base/SystemProps.java:55)
        at java.lang.System.initPhase1(java.base/System.java:1997)

I've checked the source of System.java. It seems that the implementation is not accordant with the following comments:
    /**
     * Initialize the system class.  Called after thread initialization.
     */
    private static void initPhase1() {
        // VM might invoke JNU_NewStringPlatform() to set those encoding
        // sensitive properties (user.home, user.name, boot.class.path, etc.)
        // during "props" initialization.
        // The charset is initialized in System.c and does not depend on the Properties.
        Map<String, String> tempProps = SystemProps.initProperties();
        VersionProps.init(tempProps);

        // There are certain system configurations that may be controlled by
        // VM options such as the maximum amount of direct memory and
        // Integer cache size used to support the object identity semantics
        // of autoboxing.  Typically, the library will obtain these values
        // from the properties set by the VM.  If the properties are for
        // internal implementation use only, these properties should be
        // masked from the system properties.
        //
        // Save a private copy of the system properties object that
        // can only be accessed by the internal implementation.
        VM.saveProperties(tempProps);
        props = createProperties(tempProps);
        ........

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
executing cmd: java -version

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
JVM launched, and show the correct version info.
ACTUAL -
NullPointException occured.

FREQUENCY : always



Comments
Fix request (15u) Important one-line fix for systems with Simplified Chinese. Fixed all around 15.
09-12-2021

Fix request (13u) Requesting backport to 13u for parity with 11u. The patch applies cleanly, it enables the GB18030 charset to be built into java.base on Windows.
26-01-2021

Fix Request Should get backported for parity with 11.0.11-oracle. Applies cleanly.
20-01-2021

Fix Request (jdk16u): This will prevent NullPointerExceptions being thrown when launching JVM using Simplified Chinese on Windows machines. Risk level is very low as the GB18030 charset is already present in the jdk. This change modified the stdcs-windows file to simply instruct it to be build into java.base. Patch applies cleanly to jdk16u
15-01-2021

[~chegar] Yes, thanks Chris I'll do that today
14-01-2021

[~ewhelan]] Does it make sense to port this issue to 16u also? ( if so, is that something that you can do? )
14-01-2021

Changeset: 5f7ccce0 Author: Evan Whelan <ewhelan@openjdk.org> Committer: Alan Bateman <alanb@openjdk.org> Date: 2021-01-12 20:41:04 +0000 URL: https://git.openjdk.java.net/jdk/commit/5f7ccce0
12-01-2021

The output from 9.0.4 provides a clue. Code page 54936 maps to GB18030 but GB18030 is not in java.base. We need to re-examine the langID to encoding mapping to see if there are other issues like this.
28-06-2019

From submitter: The system locale is zh_CN. I’ve tried launch jdk 12.0.1 & 11.0.1, jre 10.0.2 & 9.0.4. All the results are attached as followed. In brief, only jre 10.0.2 works fine in my system. JDK 12.0.1 PS D:\Users\tongzhigang230\Downloads\jdk-12.0.1\bin> .\java.exe -version Error occurred during initialization of VM java.lang.NullPointerException at java.lang.System.getProperty(java.base/System.java:848) at sun.security.action.GetPropertyAction.privilegedGetProperty(java.base/GetPropertyAction.java:105) at java.nio.charset.Charset.defaultCharset(java.base/Charset.java:607) at java.lang.StringCoding.decode(java.base/StringCoding.java:316) at java.lang.String.<init>(java.base/String.java:601) at java.lang.String.<init>(java.base/String.java:623) at jdk.internal.util.SystemProps$Raw.vmProperties(java.base/Native Method) at jdk.internal.util.SystemProps$Raw.cmdProperties(java.base/SystemProps.java:261) at jdk.internal.util.SystemProps.initProperties(java.base/SystemProps.java:55) at java.lang.System.initPhase1(java.base/System.java:1997) JDK 11.0.1 PS D:\Users\tongzhigang230\Downloads\jdk-11.0.1\bin> .\java.exe -version Error occurred during initialization of VM java.lang.IllegalArgumentException: Null charset name at java.nio.charset.Charset.lookup(java.base/Charset.java:455) at java.nio.charset.Charset.defaultCharset(java.base/Charset.java:608) at java.lang.StringCoding.decode(java.base/StringCoding.java:316) at java.lang.String.<init>(java.base/String.java:592) at java.lang.String.<init>(java.base/String.java:614) at java.lang.System.initProperties(java.base/Native Method) at java.lang.System.initPhase1(java.base/System.java:1942) JRE 10.0.2 PS D:\Users\tongzhigang230\Downloads\jre-10.0.2\bin> .\java.exe -version java version "10.0.2" 2018-07-17 Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13) Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode) JRE 9.0.4 PS D:\Users\tongzhigang230\Downloads\jre-9.0.4\bin> .\java.exe -version Error occurred during initialization of boot layer java.lang.ExceptionInInitializerError Caused by: java.nio.charset.UnsupportedCharsetException: GB18030
28-06-2019

There have been two or three other reports like this, we need to track down how it possible for file.encoding to be null in these environments. Information about the language and the local settings would help with that.
26-06-2019

To submitter: Can you please let us know the locale of the system on which you are experiencing the issue. Also it will be really helpful if you can let us know if you experience the same issue with JDK 9, 10 or 11 as well or is it only with the JDK 12.0.1 version that you started experiencing this issue.
26-06-2019

Looks related to JDK-8223381, moving to core-libs
24-06-2019