Please review this PR which restores the correct exception message when the 
current working directory can not be found during java startup in `initPhase1`.

Both MacOS and Linux are expected to fail with `java.lang.Error: Properties 
init: Could not determine current working directory` if the _user.dir_ system 
property cannot be initialized. Currently, MacOS now fails with 
`java.lang.InternalError: platform encoding not initialized` and Linux fails 
with  `java.lang.InternalError: null property: user.dir` which are both 
unexpected messages. 

In `System.c`, `Java_jdk_internal_util_SystemProps_00024Raw_platformProperties` 
calls `GetJavaProperties(JNIEnv *env)` which throws an internal error (with an 
appropriate message) for Unix platforms when the current working directory 
cannot be found. However, this exception is never checked and thus unexpected 
failures occur later. The expected behavior can be restored by checking if an 
exception occurred from this call and returning if so.

See _src/java.base/unix/native/libjava/java_props_md.c_ at line 520 for context 
regarding retrieving the current working directory in `GetJavaProperties(JNIEnv 
*env)`.

Testing done locally on both platforms.

-------------

Commit messages:
 - init

Changes: https://git.openjdk.org/jdk/pull/20975/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=20975&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8339769
  Stats: 2 lines in 1 file changed: 1 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/20975.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/20975/head:pull/20975

PR: https://git.openjdk.org/jdk/pull/20975

Reply via email to